Skip to main content

parse_token

Function parse_token 

Source
pub fn parse_token(s: &[u8]) -> Result<(&[u8], usize), ParseError>
Expand description

The longest token prefix of s, and its length.

The rest of s is the caller’s to check.

§Errors

ErrorKind::Empty when s does not start with a tchar.

§Examples

use parse_net::text::parse_token;

assert_eq!(parse_token(b"charset=utf-8")?, (&b"charset"[..], 7));
assert!(parse_token(b"=x").is_err());