pub fn count_lines<R: io::Read>(handle: R) -> Result<usize, io::Error> {
        let sep = b'\n';
        let mut reader = BufReader::new(handle);
        let mut count = 0;
        let mut line: Vec<u8> = Vec::new();
        while match reader.read_until(sep, &mut line) {
            Ok(n) if n > 0 => true,
            Err(e) => return Err(e),
            _ => false,
        } {
            if *line.last().unwrap() == sep {
                count += 1;
            };
        }
        Ok(count)
    }
/// Counts lines in the source `handle`.
/// count_lines(std::fs::File.open("foo.txt")
Counts lines in the source `handle`.
Counts lines in the source ` handle ` .
pub fn count_lines<R: io::Read>(handle: R) -> Result<usize, io::Error> {
        let sep = b'\n';
        let mut reader = BufReader::new(handle);
        let mut count = 0;
        let mut line: Vec<u8> = Vec::new();
        while match reader.read_until(sep, &mut line) {
            Ok(n) if n > 0 => true,
            Err(e) => return Err(e),
            _ => false,
        } {
            if *line.last().unwrap() == sep {
                count += 1;
            };
        }
        Ok(count)
    }
pub fn count_lines < R : io :: Read > ( handle : R ) -> Result < usize , io :: Error > { let sep = b'\n' ; let mut reader = BufReader :: new ( handle ) ; let mut count = 0 ; let mut line : Vec < u8 > = Vec :: new ( ) ; while match reader . read_until ( sep , & mut line ) { Ok ( n ) if n > 0 => true , Err ( e ) => return Err ( e ) , _ => false , } { if * line . last ( ) . unwrap ( ) == sep { count += 1 ; } ; } Ok ( count ) }
Counts lines in the source `handle`.
Counts lines in the source ` handle ` .
handle
R
handle
R