pub fn update_from<Chars: Iterator<Item=char>>(self, characters: Chars) -> FileLocation {
        let mut result      = self;
        let mut last_chr    = ' ';

        for chr in characters {
            // Move along one character index
            result.chr_idx    += 1;
            result.file_idx   += 1;

            match chr {
                '\n'    => {
                    if last_chr != '\r' {
                        // '\n' on its own
                        result.line     += 1;
                        result.chr_idx  = 1;
                    } else {
                        // '\r\n' - DOS line ending
                        result.chr_idx  -= 1;
                    }
                },

                '\r'    => {
                    result.line     += 1;
                    result.chr_idx  = 1;
                }

                _ => {}
            }

            last_chr = chr;
        }

        result
    }
///
/// Updates a file location from the specified set of characters
///
Updates a file location from the specified set of characters
Updates a file location from the specified set of characters
pub fn update_from<Chars: Iterator<Item=char>>(self, characters: Chars) -> FileLocation {
        let mut result      = self;
        let mut last_chr    = ' ';
        for chr in characters {
            // Move along one character index
            result.chr_idx    += 1;
            result.file_idx   += 1;
            match chr {
                '\n'    => {
                    if last_chr != '\r' {
                        // '\n' on its own
                        result.line     += 1;
                        result.chr_idx  = 1;
                    } else {
                        // '\r\n' - DOS line ending
                        result.chr_idx  -= 1;
                    }
                },
                '\r'    => {
                    result.line     += 1;
                    result.chr_idx  = 1;
                }
                _ => {}
            }
            last_chr = chr;
        }
        result
    }
pub fn update_from < Chars : Iterator < Item = char > > ( self , characters : Chars ) -> FileLocation { let mut result = self ; let mut last_chr = ' ' ; for chr in characters { // Move along one character index result . chr_idx += 1 ; result . file_idx += 1 ; match chr { '\n' => { if last_chr != '\r' { // '\n' on its own result . line += 1 ; result . chr_idx = 1 ; } else { // '\r\n' - DOS line ending result . chr_idx -= 1 ; } } , '\r' => { result . line += 1 ; result . chr_idx = 1 ; } _ => { } } last_chr = chr ; } result }
Updates a file location from the specified set of characters
Updates a file location from the specified set of characters
self
characters
Chars
self
characters
Chars