fallible/fallible.rs
1use std::{fs::File, io::Read};
2use utf8_decode::TryDecoder;
3
4fn main() -> std::io::Result<()> {
5 let file = File::open("examples/file.txt")?;
6
7 let decoder = TryDecoder::new(file.bytes());
8
9 let mut string = String::new();
10 for c in decoder {
11 string.push(c?);
12 }
13
14 println!("{}", string);
15
16 Ok(())
17}