pub fn new(buf: &'a [u8]) -> Result<(Self, &'a [u8])> {
        // Ignore leading empty lines [RFC7230§3.5].
        let start = skip_empty_lines(buf)?;

        // Retrieve contents of initial line and split by spaces.
        let (line, rest) = next_line(start)?;
        let line = std::str::from_utf8(line).map_err(|_| Error::Syntax)?;

        let mut chunks = line.split(' ');
        let method = chunks.next().ok_or(Error::Syntax)?;
        let target = chunks.next().ok_or(Error::Syntax)?;
        let version = chunks.next().ok_or(Error::Syntax)?;

        if chunks.next().is_some() {
            return Err(Error::Syntax);
        }

        Ok((RequestLine { method, target, version }, rest))
    }
/// Try to parse the given bytes into `RequestLine` components.
///
/// On success, return `Ok((rl, rest))`, where `rl` is the `RequestLine` and `rest` is
/// a slice that begins directly after the Request-Line terminating CRLF.
Try to parse the given bytes into `RequestLine` components.
Try to parse the given bytes into ` RequestLine ` components .
pub fn new(buf: &'a [u8]) -> Result<(Self, &'a [u8])> {
        // Ignore leading empty lines [RFC7230§3.5].
        let start = skip_empty_lines(buf)?;
        // Retrieve contents of initial line and split by spaces.
        let (line, rest) = next_line(start)?;
        let line = std::str::from_utf8(line).map_err(|_| Error::Syntax)?;
        let mut chunks = line.split(' ');
        let method = chunks.next().ok_or(Error::Syntax)?;
        let target = chunks.next().ok_or(Error::Syntax)?;
        let version = chunks.next().ok_or(Error::Syntax)?;
        if chunks.next().is_some() {
            return Err(Error::Syntax);
        }
        Ok((RequestLine { method, target, version }, rest))
    }
pub fn new ( buf : & ' a [ u8 ] ) -> Result < ( Self , & ' a [ u8 ] ) > { // Ignore leading empty lines [RFC7230§3.5]. let start = skip_empty_lines ( buf ) ? ; // Retrieve contents of initial line and split by spaces. let ( line , rest ) = next_line ( start ) ? ; let line = std :: str :: from_utf8 ( line ) . map_err ( | _ | Error :: Syntax ) ? ; let mut chunks = line . split ( ' ' ) ; let method = chunks . next ( ) . ok_or ( Error :: Syntax ) ? ; let target = chunks . next ( ) . ok_or ( Error :: Syntax ) ? ; let version = chunks . next ( ) . ok_or ( Error :: Syntax ) ? ; if chunks . next ( ) . is_some ( ) { return Err ( Error :: Syntax ) ; } Ok ( ( RequestLine { method , target , version } , rest ) ) }
Try to parse the given bytes into `RequestLine` components.
Try to parse the given bytes into ` RequestLine ` components .
buf
&'a [u8]
buf
&'a [u8]