Update io iterators to produce IoResults
Most IO related functions return an IoResult so that the caller can handle failure in whatever way is appropriate. However, the `lines`, `bytes`, and `chars` iterators all supress errors. This means that code that needs to handle errors can't use any of these iterators. All three of these iterators were updated to produce IoResults. Fixes #12368
This commit is contained in:
parent
2eebeb8137
commit
9ba6bb5a71
7 changed files with 57 additions and 49 deletions
|
|
@ -182,7 +182,7 @@ fn main() {
|
|||
let mut proc_mode = false;
|
||||
|
||||
for line in rdr.lines() {
|
||||
let line = line.trim().to_owned();
|
||||
let line = line.unwrap().trim().to_owned();
|
||||
|
||||
if line.len() == 0u { continue; }
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ impl Sudoku {
|
|||
|
||||
let mut g = vec::from_fn(10u, { |_i| ~[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] });
|
||||
for line in reader.lines() {
|
||||
let comps: ~[&str] = line.trim().split(',').collect();
|
||||
let comps: ~[&str] = line.unwrap().trim().split(',').collect();
|
||||
|
||||
if comps.len() == 3u {
|
||||
let row = from_str::<uint>(comps[0]).unwrap() as u8;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue