Comments can also be //

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2023-01-11 18:24:02 +01:00
parent 4fdc467cf2
commit 692cb204ac
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -51,7 +51,7 @@ fn allspaces(i: &str) -> IResult<&str, &str> {
}
fn comment(i: &str) -> IResult<&str, &str> {
let (i, _) = delimited(tag("#"), take_until("\n"), tag("\n"))(i)?;
let (i, _) = delimited(alt((tag("#"), tag("//"))), take_until("\n"), tag("\n"))(i)?;
Ok((i, ""))
}
@ -226,6 +226,9 @@ mod tests {
Err(_) => (),
err => panic!("Unexpected result: {:?}", err),
}
let buf4 = "// Foo\n";
assert_eq!(comment(buf4), Ok(("", "")));
}
#[test]