diff --git a/src/character/mod.rs b/src/character/mod.rs index c2c7f45d3..4c70f6e2c 100644 --- a/src/character/mod.rs +++ b/src/character/mod.rs @@ -113,4 +113,4 @@ pub fn is_space(chr: u8) -> bool { #[inline] pub fn is_newline(chr: u8) -> bool { chr == b'\n' -} \ No newline at end of file +} diff --git a/src/internal.rs b/src/internal.rs index 4454abffb..47382ee58 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -35,12 +35,12 @@ pub trait Finish { impl Finish for IResult { fn finish(self) -> Result<(I, O), E> { match self { - Ok(res) => Ok(res), - Err(Err::Error(e)) | Err(Err::Failure(e)) => Err(e), - Err(Err::Incomplete(_)) => { - panic!("Cannot call `finish()` on `Err(Err::Incomplete(_))`: this result means that the parser does not have enough data to decide, you should gather more data and try to reapply the parser instead") - } - } + Ok(res) => Ok(res), + Err(Err::Error(e)) | Err(Err::Failure(e)) => Err(e), + Err(Err::Incomplete(_)) => { + panic!("Cannot call `finish()` on `Err(Err::Incomplete(_))`: this result means that the parser does not have enough data to decide, you should gather more data and try to reapply the parser instead") + } + } } } diff --git a/src/multi/macros.rs b/src/multi/macros.rs index 5179e0cac..7599ba60a 100644 --- a/src/multi/macros.rs +++ b/src/multi/macros.rs @@ -614,7 +614,10 @@ mod tests { let i_err_pos = &i[3..]; assert_eq!( empty_sep(i), - Err(Err::Error(error_position!(i_err_pos, ErrorKind::SeparatedList))) + Err(Err::Error(error_position!( + i_err_pos, + ErrorKind::SeparatedList + ))) ); let res4 = vec![&b"abcd"[..], &b"abcd"[..]]; assert_eq!(multi(e), Ok((&b",ef"[..], res4))); diff --git a/src/multi/mod.rs b/src/multi/mod.rs index 6042e3e1c..32b7d9ad7 100644 --- a/src/multi/mod.rs +++ b/src/multi/mod.rs @@ -726,7 +726,11 @@ where /// assert_eq!(parser("123123"), Ok(("123123", vec![]))); /// assert_eq!(parser(""), Ok(("", vec![]))); /// ``` -pub fn fold_many0(mut f: F, init: R, mut g: G) -> impl FnMut(I) -> IResult +pub fn fold_many0( + mut f: F, + init: R, + mut g: G, +) -> impl FnMut(I) -> IResult where I: Clone + PartialEq, F: Parser, @@ -804,7 +808,11 @@ where /// assert_eq!(parser("123123"), Err(Err::Error(Error::new("123123", ErrorKind::Many1)))); /// assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::Many1)))); /// ``` -pub fn fold_many1(mut f: F, init: R, mut g: G) -> impl FnMut(I) -> IResult +pub fn fold_many1( + mut f: F, + init: R, + mut g: G, +) -> impl FnMut(I) -> IResult where I: Clone + PartialEq, F: Parser, diff --git a/src/regexp/macros.rs b/src/regexp/macros.rs index 6d51a28fd..ff84787fe 100644 --- a/src/regexp/macros.rs +++ b/src/regexp/macros.rs @@ -55,7 +55,10 @@ macro_rules! re_bytes_find ( /// /// Requires the `regexp` feature. #[macro_export(local_inner_macros)] -#[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] +#[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) +)] macro_rules! re_matches ( ($i:expr, $re:expr) => ( { let r = $crate::lib::regex::Regex::new($re).unwrap(); @@ -68,7 +71,10 @@ macro_rules! re_matches ( /// /// Requires the `regexp` feature. #[macro_export(local_inner_macros)] -#[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] +#[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) +)] macro_rules! re_bytes_matches ( ($i:expr, $re:expr) => ( { let r = $crate::lib::regex::bytes::Regex::new($re).unwrap(); @@ -81,7 +87,10 @@ macro_rules! re_bytes_matches ( /// /// Requires the `regexp` feature. #[macro_export(local_inner_macros)] -#[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] +#[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) +)] macro_rules! re_capture ( ($i:expr, $re:expr) => ( { let r = $crate::lib::regex::Regex::new($re).unwrap(); @@ -94,7 +103,10 @@ macro_rules! re_capture ( /// /// Requires the `regexp` feature. #[macro_export(local_inner_macros)] -#[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] +#[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) +)] macro_rules! re_bytes_capture ( ($i:expr, $re:expr) => ( { let r = $crate::lib::regex::bytes::Regex::new($re).unwrap(); @@ -108,7 +120,10 @@ macro_rules! re_bytes_capture ( /// /// Requires the `regexp` feature. #[macro_export(local_inner_macros)] -#[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] +#[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) +)] macro_rules! re_captures ( ($i:expr, $re:expr) => ( { let r = $crate::lib::regex::Regex::new($re).unwrap(); @@ -121,7 +136,10 @@ macro_rules! re_captures ( /// /// Requires the `regexp` feature. #[macro_export(local_inner_macros)] -#[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] +#[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) +)] macro_rules! re_bytes_captures ( ($i:expr, $re:expr) => ( { let r = $crate::lib::regex::bytes::Regex::new($re).unwrap(); diff --git a/src/regexp/mod.rs b/src/regexp/mod.rs index 20f60a423..b1b856c91 100644 --- a/src/regexp/mod.rs +++ b/src/regexp/mod.rs @@ -59,7 +59,10 @@ pub mod str { /// # } /// ``` #[cfg(all(feature = "regexp", feature = "alloc"))] - #[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] + #[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) + )] pub fn re_matches<'a, E>(re: Regex) -> impl Fn(&'a str) -> IResult<&'a str, Vec<&'a str>, E> where E: ParseError<&'a str>, @@ -130,7 +133,10 @@ pub mod str { /// # } /// ``` #[cfg(all(feature = "regexp", feature = "alloc"))] - #[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] + #[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) + )] pub fn re_capture<'a, E>(re: Regex) -> impl Fn(&'a str) -> IResult<&'a str, Vec<&'a str>, E> where E: ParseError<&'a str>, @@ -171,7 +177,10 @@ pub mod str { /// # } /// ``` #[cfg(all(feature = "regexp", feature = "alloc"))] - #[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] + #[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) + )] pub fn re_captures<'a, E>(re: Regex) -> impl Fn(&'a str) -> IResult<&'a str, Vec>, E> where E: ParseError<&'a str>, @@ -361,7 +370,10 @@ pub mod bytes { /// # } /// ``` #[cfg(all(feature = "regexp", feature = "alloc"))] - #[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] + #[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) + )] pub fn re_matches<'a, E>(re: Regex) -> impl Fn(&'a [u8]) -> IResult<&'a [u8], Vec<&'a [u8]>, E> where E: ParseError<&'a [u8]>, @@ -431,7 +443,10 @@ pub mod bytes { /// # } /// ``` #[cfg(all(feature = "regexp", feature = "alloc"))] - #[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] + #[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) + )] pub fn re_capture<'a, E>(re: Regex) -> impl Fn(&'a [u8]) -> IResult<&'a [u8], Vec<&'a [u8]>, E> where E: ParseError<&'a [u8]>, @@ -472,7 +487,10 @@ pub mod bytes { /// # } /// ``` #[cfg(all(feature = "regexp", feature = "alloc"))] - #[cfg_attr(feature = "docsrs", doc(cfg(all(feature = "regexp", feature = "alloc"))))] + #[cfg_attr( + feature = "docsrs", + doc(cfg(all(feature = "regexp", feature = "alloc"))) + )] pub fn re_captures<'a, E>( re: Regex, ) -> impl Fn(&'a [u8]) -> IResult<&'a [u8], Vec>, E> diff --git a/tests/issues.rs b/tests/issues.rs index 6788f7220..3ffc2718e 100644 --- a/tests/issues.rs +++ b/tests/issues.rs @@ -350,16 +350,11 @@ named!(issue_962<&[u8], Vec<&[u8]>>, #[test] fn issue_1231_bits_expect_fn_closure() { - use nom::bits::{bits, complete::take}; - use nom::error::Error; - use nom::sequence::tuple; - pub fn example(input: &[u8]) -> IResult<&[u8], (u8, u8)> { - bits::<_, _, Error<_>, _, _>(tuple(( - take(1usize), take(1usize) - )))(input) - } - assert_eq!( - example(&[0xff]), - Ok((&b""[..], (1, 1))) - ); + use nom::bits::{bits, complete::take}; + use nom::error::Error; + use nom::sequence::tuple; + pub fn example(input: &[u8]) -> IResult<&[u8], (u8, u8)> { + bits::<_, _, Error<_>, _, _>(tuple((take(1usize), take(1usize))))(input) + } + assert_eq!(example(&[0xff]), Ok((&b""[..], (1, 1)))); }