d
Size: a a a
d
K
d
a
EG
a
EG
EG
a
АК
IB
АК
IB
IB
Z
IB
АК
use std::io;
use std::io::BufReader;
use std::io::prelude::*;
pub fn run() -> std::io::Result<()> {
let buf_capacity = 512;
let stdin = io::stdin();
let mut reader = BufReader::with_capacity(buf_capacity, stdin);
let mut counter = 0;
loop {
reader.fill_buf()?;
counter += reader.buffer().iter().fold(0, |acc, x| if x == &10 { acc + 1 } else { acc });
if reader.buffer().len() == 0 {
break
};
reader.consume(buf_capacity);
}
println!("There is {} records", counter);
Ok(())
}
IB
use std::io;
use std::io::BufReader;
use std::io::prelude::*;
pub fn run() -> std::io::Result<()> {
let buf_capacity = 512;
let stdin = io::stdin();
let mut reader = BufReader::with_capacity(buf_capacity, stdin);
let mut counter = 0;
loop {
reader.fill_buf()?;
counter += reader.buffer().iter().fold(0, |acc, x| if x == &10 { acc + 1 } else { acc });
if reader.buffer().len() == 0 {
break
};
reader.consume(buf_capacity);
}
println!("There is {} records", counter);
Ok(())
}
b'\n'
по-другому (filter+count, что оказалось медленнее).IB
b'\n'
.АК