fn decode_escaped_string(&self, slice: &[u8]) -> Result<Value> {
        // Remove quotes if they appear.
        let slice = if (slice.len() >= 2) &&
            (slice[0] == slice[slice.len() - 1]) &&
            (slice[0] == b'"' || slice[0] == b'\'')
        {
            &slice[1..slice.len() - 1]
        } else {
            slice
        };
        let mut result = Vec::with_capacity(slice.len());
        let mut iter = slice.iter();
        while let Some(&b) = iter.next() {
            match b {
                b'\\' => match iter.next() {
                    Some(&b'\\') => result.push(b'\\'),
                    Some(&b'a') => result.push(b'\x07'),
                    Some(&b'b') => result.push(b'\x08'),
                    Some(&b't') => result.push(b'\x09'),
                    Some(&b'n') => result.push(b'\x0a'),
                    Some(&b'v') => result.push(b'\x0b'),
                    Some(&b'f') => result.push(b'\x0c'),
                    Some(&b'r') => result.push(b'\x0d'),
                    Some(&b'x') => {
                        match iter.next()
                                  .and_then(|&ch1| (ch1 as char).to_digit(16))
                                  .and_then(|v1| iter.next()
                                            .and_then(|&ch2| (ch2 as char).to_digit(16))
                                            .map(|v2| 16*(v1 as u8) + (v2 as u8)))
                        {
                            Some(v) => result.push(v),
                            None => return self.error(ErrorCode::InvalidLiteral(slice.into()))
                        }
                    },
                    _ => return self.error(ErrorCode::InvalidLiteral(slice.into())),
                },
                _ => result.push(b)
            }
        }
        self.decode_string(result)
    }
// Decode an escaped string.  These are encoded with "normal" Python string
// escape rules.
Decode an escaped string.  These are encoded with "normal" Python string
escape rules.
Decode an escaped string . These are encoded with " normal " Python string escape rules .
fn decode_escaped_string(&self, slice: &[u8]) -> Result<Value> {
        // Remove quotes if they appear.
        let slice = if (slice.len() >= 2) &&
            (slice[0] == slice[slice.len() - 1]) &&
            (slice[0] == b'"' || slice[0] == b'\'')
        {
            &slice[1..slice.len() - 1]
        } else {
            slice
        };
        let mut result = Vec::with_capacity(slice.len());
        let mut iter = slice.iter();
        while let Some(&b) = iter.next() {
            match b {
                b'\\' => match iter.next() {
                    Some(&b'\\') => result.push(b'\\'),
                    Some(&b'a') => result.push(b'\x07'),
                    Some(&b'b') => result.push(b'\x08'),
                    Some(&b't') => result.push(b'\x09'),
                    Some(&b'n') => result.push(b'\x0a'),
                    Some(&b'v') => result.push(b'\x0b'),
                    Some(&b'f') => result.push(b'\x0c'),
                    Some(&b'r') => result.push(b'\x0d'),
                    Some(&b'x') => {
                        match iter.next()
                                  .and_then(|&ch1| (ch1 as char).to_digit(16))
                                  .and_then(|v1| iter.next()
                                            .and_then(|&ch2| (ch2 as char).to_digit(16))
                                            .map(|v2| 16*(v1 as u8) + (v2 as u8)))
                        {
                            Some(v) => result.push(v),
                            None => return self.error(ErrorCode::InvalidLiteral(slice.into()))
                        }
                    },
                    _ => return self.error(ErrorCode::InvalidLiteral(slice.into())),
                },
                _ => result.push(b)
            }
        }
        self.decode_string(result)
    }
fn decode_escaped_string ( & self , slice : & [ u8 ] ) -> Result < Value > { // Remove quotes if they appear. let slice = if ( slice . len ( ) >= 2 ) && ( slice [ 0 ] == slice [ slice . len ( ) - 1 ] ) && ( slice [ 0 ] == b'"' || slice [ 0 ] == b'\'' ) { & slice [ 1 .. slice . len ( ) - 1 ] } else { slice } ; let mut result = Vec :: with_capacity ( slice . len ( ) ) ; let mut iter = slice . iter ( ) ; while let Some ( & b ) = iter . next ( ) { match b { b'\\' => match iter . next ( ) { Some ( & b'\\' ) => result . push ( b'\\' ) , Some ( & b'a' ) => result . push ( b'\x07' ) , Some ( & b'b' ) => result . push ( b'\x08' ) , Some ( & b't' ) => result . push ( b'\x09' ) , Some ( & b'n' ) => result . push ( b'\x0a' ) , Some ( & b'v' ) => result . push ( b'\x0b' ) , Some ( & b'f' ) => result . push ( b'\x0c' ) , Some ( & b'r' ) => result . push ( b'\x0d' ) , Some ( & b'x' ) => { match iter . next ( ) . and_then ( | & ch1 | ( ch1 as char ) . to_digit ( 16 ) ) . and_then ( | v1 | iter . next ( ) . and_then ( | & ch2 | ( ch2 as char ) . to_digit ( 16 ) ) . map ( | v2 | 16 * ( v1 as u8 ) + ( v2 as u8 ) ) ) { Some ( v ) => result . push ( v ) , None => return self . error ( ErrorCode :: InvalidLiteral ( slice . into ( ) ) ) } } , _ => return self . error ( ErrorCode :: InvalidLiteral ( slice . into ( ) ) ) , } , _ => result . push ( b ) } } self . decode_string ( result ) }
Decode an escaped string.
Decode an escaped string .
&self
slice
&[u8]
&self
slice
&[u8]