1 extern crate bstr; 2 3 use std::error::Error; 4 use std::io; 5 6 use bstr::{io::BufReadExt, ByteSlice}; 7 main() -> Result<(), Box<dyn Error>>8fn main() -> Result<(), Box<dyn Error>> { 9 let stdin = io::stdin(); 10 let mut words = 0; 11 stdin.lock().for_byte_line_with_terminator(|line| { 12 words += line.words().count(); 13 Ok(true) 14 })?; 15 println!("{}", words); 16 Ok(()) 17 } 18