Skip to content

Commit

Permalink
update nom 6.1.2 and fix compile errors. (#1806)
Browse files Browse the repository at this point in the history
  • Loading branch information
higumachan authored Apr 2, 2021
1 parent bf3d979 commit bad4c77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/yew-router-route-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ description = "The parser for the routing syntax used with yew-router"
repository = "https://github.com/yewstack/yew"

[dependencies]
nom = "5.0.0"
nom = "6.1.2"
11 changes: 5 additions & 6 deletions packages/yew-router-route-parser/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use nom::{
is_digit,
},
combinator::{map, map_parser},
error::ErrorKind,
sequence::{delimited, separated_pair},
IResult,
};
Expand Down Expand Up @@ -84,11 +83,11 @@ fn get_colon(i: &str) -> IResult<&str, (), ParseError> {
.map_err(|_: nom::Err<()>| nom::Err::Error(ParseError::expected(ExpectedToken::Colon)))
}

fn rust_ident(i: &str) -> IResult<&str, &str, ParseError> {
fn rust_ident<'a>(i: &'a str) -> IResult<&'a str, &'a str, ParseError> {
let invalid_ident_chars = r##" \|/{[]()?+=-!@#$%^&*~`'";:"##;
// Detect an ident by first reading until a } is found,
// then validating the captured section against invalid characters that can't be in rust idents.
map_parser(take_till1(move |c| c == '}'), move |i: &str| {
map_parser(take_till1(move |c| c == '}'), move |i: &'a str| {
match take_till1::<_, _, ()>(|c| invalid_ident_chars.contains(c))(i) {
Ok((remain, got)) => {
// Detects if the first character is a digit.
Expand Down Expand Up @@ -151,9 +150,9 @@ fn exact_impl(special_chars: &'static str) -> impl Fn(&str) -> IResult<&str, &st
take_till1(move |c| special_chars.contains(c)),
escaped_item_impl,
))(i)
.map_err(|x: nom::Err<(&str, ErrorKind)>| {
.map_err(|x: nom::Err<nom::error::Error<&str>>| {
let s = match x {
nom::Err::Error((s, _)) | nom::Err::Failure((s, _)) => s,
nom::Err::Error(e) | nom::Err::Failure(e) => e.input,
nom::Err::Incomplete(_) => panic!(),
};
nom::Err::Error(ParseError {
Expand All @@ -179,7 +178,7 @@ pub fn fragment_exact(i: &str) -> IResult<&str, RouteParserToken, ParseError> {

pub fn capture<'a>(
field_naming_scheme: FieldNamingScheme,
) -> impl Fn(&'a str) -> IResult<&'a str, RouteParserToken<'a>, ParseError> {
) -> impl FnMut(&'a str) -> IResult<&'a str, RouteParserToken<'a>, ParseError> {
map(capture_impl(field_naming_scheme), RouteParserToken::Capture)
}

Expand Down

0 comments on commit bad4c77

Please sign in to comment.