fn render(line: &str) -> String {
        // count tabs so we only need to make a single allocation
        let tabs = line.as_bytes().iter().filter(|c| **c == b'\t').count();
        let mut rendered: Vec<u8> = Vec::with_capacity(line.len() + tabs * (TABSTOP - 1));
        let mut r_index = 0;
        for c in line.as_bytes() {
            if *c == b'\t' {
                rendered.push(b' ');
                r_index += 1;
                while r_index % TABSTOP != 0 {
                    rendered.push(b' ');
                    r_index += 1;
                }
            } else {
                rendered.push(*c);
                r_index += 1;
            }
        }
        std::string::String::from_utf8(rendered).unwrap()
    }
/// Change source text into what is displated
///
/// Expands tabs into spaces according to TABSTOP
Change source text into what is displated
Expands tabs into spaces according to TABSTOP
Change source text into what is displated Expands tabs into spaces according to TABSTOP
fn render(line: &str) -> String {
        // count tabs so we only need to make a single allocation
        let tabs = line.as_bytes().iter().filter(|c| **c == b'\t').count();
        let mut rendered: Vec<u8> = Vec::with_capacity(line.len() + tabs * (TABSTOP - 1));
        let mut r_index = 0;
        for c in line.as_bytes() {
            if *c == b'\t' {
                rendered.push(b' ');
                r_index += 1;
                while r_index % TABSTOP != 0 {
                    rendered.push(b' ');
                    r_index += 1;
                }
            } else {
                rendered.push(*c);
                r_index += 1;
            }
        }
        std::string::String::from_utf8(rendered).unwrap()
    }
fn render ( line : & str ) -> String { // count tabs so we only need to make a single allocation let tabs = line . as_bytes ( ) . iter ( ) . filter ( | c | * * c == b'\t' ) . count ( ) ; let mut rendered : Vec < u8 > = Vec :: with_capacity ( line . len ( ) + tabs * ( TABSTOP - 1 ) ) ; let mut r_index = 0 ; for c in line . as_bytes ( ) { if * c == b'\t' { rendered . push ( b' ' ) ; r_index += 1 ; while r_index % TABSTOP != 0 { rendered . push ( b' ' ) ; r_index += 1 ; } } else { rendered . push ( * c ) ; r_index += 1 ; } } std :: string :: String :: from_utf8 ( rendered ) . unwrap ( ) }
Change source text into what is displated
Expands tabs into spaces according to TABSTOP
Change source text into what is displated Expands tabs into spaces according to TABSTOP
line
&str