pub fn string_single_quoted(span: Span) -> Result<Span, Literal> {
    let input        = span.as_slice();
    let input_length = span.input_len();

    if input_length < 2 {
        return Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::TooShort as u32))));
    }

    if input[0] == b'b' || input[0] == b'B' {
        if input_length < 3 {
            return Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::TooShort as u32))));
        } else if input[1] != b'\'' {
            return Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::InvalidOpeningCharacter as u32))));
        } else {
            return string_single_quoted(span.slice(1..));
        }
    } else if input[0] != b'\'' {
        return Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::InvalidOpeningCharacter as u32))));
    }

    let mut output: Option<Cow<[u8]>> = None;
    let mut offset                    = 1;
    let mut iterator                  = input[offset..].iter().enumerate();
    let mut range;

    while let Some((index, item)) = iterator.next() {
        if *item == b'\\' {
            if let Some((next_index, next_item)) = iterator.next() {
                if *next_item == b'\'' ||
                   *next_item == b'\\' {
                    range = offset..index + 1;

                    if let None = output {
                        output = Some(Cow::Borrowed(&input[range]));
                    } else if let Some(data) = output.as_mut() {
                        data.to_mut().extend(&input[range]);
                    }

                    offset = next_index + 1;
                }
            } else {
                return Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::InvalidClosingCharacter as u32))));
            }
        } else if *item == b'\'' {
            range = offset..index + 1;

            if let None = output {
                output = Some(Cow::Borrowed(&input[range]));
            } else if let Some(data) = output.as_mut() {
                data.to_mut().extend(&input[range]);
            }

            return Ok((
                span.slice(index + 2..),
                Literal::String(Token::new(output.unwrap(), span.slice(..index + 2)))
            ));
        }
    }

    Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::InvalidClosingCharacter as u32))))
}
/// Recognize a single quoted string.
///
/// See the `string` parser for more details.
Recognize a single quoted string.
See the `string` parser for more details.
Recognize a single quoted string . See the ` string ` parser for more details .
pub fn string_single_quoted(span: Span) -> Result<Span, Literal> {
    let input        = span.as_slice();
    let input_length = span.input_len();
    if input_length < 2 {
        return Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::TooShort as u32))));
    }
    if input[0] == b'b' || input[0] == b'B' {
        if input_length < 3 {
            return Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::TooShort as u32))));
        } else if input[1] != b'\'' {
            return Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::InvalidOpeningCharacter as u32))));
        } else {
            return string_single_quoted(span.slice(1..));
        }
    } else if input[0] != b'\'' {
        return Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::InvalidOpeningCharacter as u32))));
    }
    let mut output: Option<Cow<[u8]>> = None;
    let mut offset                    = 1;
    let mut iterator                  = input[offset..].iter().enumerate();
    let mut range;
    while let Some((index, item)) = iterator.next() {
        if *item == b'\\' {
            if let Some((next_index, next_item)) = iterator.next() {
                if *next_item == b'\'' ||
                   *next_item == b'\\' {
                    range = offset..index + 1;
                    if let None = output {
                        output = Some(Cow::Borrowed(&input[range]));
                    } else if let Some(data) = output.as_mut() {
                        data.to_mut().extend(&input[range]);
                    }
                    offset = next_index + 1;
                }
            } else {
                return Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::InvalidClosingCharacter as u32))));
            }
        } else if *item == b'\'' {
            range = offset..index + 1;
            if let None = output {
                output = Some(Cow::Borrowed(&input[range]));
            } else if let Some(data) = output.as_mut() {
                data.to_mut().extend(&input[range]);
            }
            return Ok((
                span.slice(index + 2..),
                Literal::String(Token::new(output.unwrap(), span.slice(..index + 2)))
            ));
        }
    }
    Err(Error::Error(Context::Code(span, ErrorKind::Custom(StringError::InvalidClosingCharacter as u32))))
}
pub fn string_single_quoted ( span : Span ) -> Result < Span , Literal > { let input = span . as_slice ( ) ; let input_length = span . input_len ( ) ; if input_length < 2 { return Err ( Error :: Error ( Context :: Code ( span , ErrorKind :: Custom ( StringError :: TooShort as u32 ) ) ) ) ; } if input [ 0 ] == b'b' || input [ 0 ] == b'B' { if input_length < 3 { return Err ( Error :: Error ( Context :: Code ( span , ErrorKind :: Custom ( StringError :: TooShort as u32 ) ) ) ) ; } else if input [ 1 ] != b'\'' { return Err ( Error :: Error ( Context :: Code ( span , ErrorKind :: Custom ( StringError :: InvalidOpeningCharacter as u32 ) ) ) ) ; } else { return string_single_quoted ( span . slice ( 1 .. ) ) ; } } else if input [ 0 ] != b'\'' { return Err ( Error :: Error ( Context :: Code ( span , ErrorKind :: Custom ( StringError :: InvalidOpeningCharacter as u32 ) ) ) ) ; } let mut output : Option < Cow < [ u8 ] > > = None ; let mut offset = 1 ; let mut iterator = input [ offset .. ] . iter ( ) . enumerate ( ) ; let mut range ; while let Some ( ( index , item ) ) = iterator . next ( ) { if * item == b'\\' { if let Some ( ( next_index , next_item ) ) = iterator . next ( ) { if * next_item == b'\'' || * next_item == b'\\' { range = offset .. index + 1 ; if let None = output { output = Some ( Cow :: Borrowed ( & input [ range ] ) ) ; } else if let Some ( data ) = output . as_mut ( ) { data . to_mut ( ) . extend ( & input [ range ] ) ; } offset = next_index + 1 ; } } else { return Err ( Error :: Error ( Context :: Code ( span , ErrorKind :: Custom ( StringError :: InvalidClosingCharacter as u32 ) ) ) ) ; } } else if * item == b'\'' { range = offset .. index + 1 ; if let None = output { output = Some ( Cow :: Borrowed ( & input [ range ] ) ) ; } else if let Some ( data ) = output . as_mut ( ) { data . to_mut ( ) . extend ( & input [ range ] ) ; } return Ok ( ( span . slice ( index + 2 .. ) , Literal :: String ( Token :: new ( output . unwrap ( ) , span . slice ( .. index + 2 ) ) ) ) ) ; } } Err ( Error :: Error ( Context :: Code ( span , ErrorKind :: Custom ( StringError :: InvalidClosingCharacter as u32 ) ) ) ) }
Recognize a single quoted string.
Recognize a single quoted string .
span
Span