Skip to main content

parse_comment

Function parse_comment 

Source
pub fn parse_comment(input: &str) -> IResult<&str, String>
Expand description

Parse a comment line (starts with #)

Comments in magic files start with ‘#’ and continue to the end of the line. This function consumes the entire comment line.

§Examples

use libmagic_rs::parser::grammar::parse_comment;

assert_eq!(parse_comment("# This is a comment"), Ok(("", "This is a comment".to_string())));
assert_eq!(parse_comment("#"), Ok(("", "".to_string())));

Parse a comment line (starting with #)

§Errors

Returns a nom parsing error if the input is not a valid comment