infallible/infallible.rs
1use utf8_decode::{Decoder, Utf8Error};
2
3fn main() -> Result<(), Utf8Error> {
4 let bytes = [
5 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 32, 240, 159, 140, 141,
6 ];
7
8 let decoder = Decoder::new(bytes.iter().cloned());
9
10 let mut string = String::new();
11 for c in decoder {
12 string.push(c?);
13 }
14
15 println!("{}", string);
16
17 Ok(())
18}