unsafe/
unsafe.rs

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