fn translate_crlf<'b>(&self, start: BytePos,
                          s: &'b str, errmsg: &'b str) -> Cow<'b, str> {
        let mut i = 0;
        while i < s.len() {
            let ch = char_at(s, i);
            let next = i + ch.len_utf8();
            if ch == '\r' {
                if next < s.len() && char_at(s, next) == '\n' {
                    return translate_crlf_(self, start, s, errmsg, i).into();
                }
                let pos = start + BytePos(i as u32);
                let end_pos = start + BytePos(next as u32);
                self.err_span_(pos, end_pos, errmsg);
            }
            i = next;
        }
        return s.into();

        fn translate_crlf_(rdr: &StringReader, start: BytePos,
                        s: &str, errmsg: &str, mut i: usize) -> String {
            let mut buf = String::with_capacity(s.len());
            let mut j = 0;
            while i < s.len() {
                let ch = char_at(s, i);
                let next = i + ch.len_utf8();
                if ch == '\r' {
                    if j < i { buf.push_str(&s[j..i]); }
                    j = next;
                    if next >= s.len() || char_at(s, next) != '\n' {
                        let pos = start + BytePos(i as u32);
                        let end_pos = start + BytePos(next as u32);
                        rdr.err_span_(pos, end_pos, errmsg);
                    }
                }
                i = next;
            }
            if j < s.len() { buf.push_str(&s[j..]); }
            buf
        }
    }
/// Converts CRLF to LF in the given string, raising an error on bare CR.
Converts CRLF to LF in the given string, raising an error on bare CR.
Converts CRLF to LF in the given string raising an error on bare CR .
fn translate_crlf<'b>(&self, start: BytePos,
                          s: &'b str, errmsg: &'b str) -> Cow<'b, str> {
        let mut i = 0;
        while i < s.len() {
            let ch = char_at(s, i);
            let next = i + ch.len_utf8();
            if ch == '\r' {
                if next < s.len() && char_at(s, next) == '\n' {
                    return translate_crlf_(self, start, s, errmsg, i).into();
                }
                let pos = start + BytePos(i as u32);
                let end_pos = start + BytePos(next as u32);
                self.err_span_(pos, end_pos, errmsg);
            }
            i = next;
        }
        return s.into();
        fn translate_crlf_(rdr: &StringReader, start: BytePos,
                        s: &str, errmsg: &str, mut i: usize) -> String {
            let mut buf = String::with_capacity(s.len());
            let mut j = 0;
            while i < s.len() {
                let ch = char_at(s, i);
                let next = i + ch.len_utf8();
                if ch == '\r' {
                    if j < i { buf.push_str(&s[j..i]); }
                    j = next;
                    if next >= s.len() || char_at(s, next) != '\n' {
                        let pos = start + BytePos(i as u32);
                        let end_pos = start + BytePos(next as u32);
                        rdr.err_span_(pos, end_pos, errmsg);
                    }
                }
                i = next;
            }
            if j < s.len() { buf.push_str(&s[j..]); }
            buf
        }
    }
fn translate_crlf < ' b > ( & self , start : BytePos , s : & ' b str , errmsg : & ' b str ) -> Cow < ' b , str > { let mut i = 0 ; while i < s . len ( ) { let ch = char_at ( s , i ) ; let next = i + ch . len_utf8 ( ) ; if ch == '\r' { if next < s . len ( ) && char_at ( s , next ) == '\n' { return translate_crlf_ ( self , start , s , errmsg , i ) . into ( ) ; } let pos = start + BytePos ( i as u32 ) ; let end_pos = start + BytePos ( next as u32 ) ; self . err_span_ ( pos , end_pos , errmsg ) ; } i = next ; } return s . into ( ) ; fn translate_crlf_ ( rdr : & StringReader , start : BytePos , s : & str , errmsg : & str , mut i : usize ) -> String { let mut buf = String :: with_capacity ( s . len ( ) ) ; let mut j = 0 ; while i < s . len ( ) { let ch = char_at ( s , i ) ; let next = i + ch . len_utf8 ( ) ; if ch == '\r' { if j < i { buf . push_str ( & s [ j .. i ] ) ; } j = next ; if next >= s . len ( ) || char_at ( s , next ) != '\n' { let pos = start + BytePos ( i as u32 ) ; let end_pos = start + BytePos ( next as u32 ) ; rdr . err_span_ ( pos , end_pos , errmsg ) ; } } i = next ; } if j < s . len ( ) { buf . push_str ( & s [ j .. ] ) ; } buf } }
Converts CRLF to LF in the given string, raising an error on bare CR.
Converts CRLF to LF in the given string raising an error on bare CR .
&self
start
BytePos
s
&'b str
errmsg
&'b str