cargo fmt

This commit is contained in:
Greg Shuflin 2023-02-25 02:50:43 -08:00
parent f15488194c
commit 377d515d40
2 changed files with 16 additions and 13 deletions

View File

@ -1,12 +1,12 @@
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Representation { pub struct Representation {
val: String val: String,
} }
impl Representation { impl Representation {
pub fn new(from: &str) -> Self { pub fn new(from: &str) -> Self {
Self { val: from.to_string() } Self {
val: from.to_string(),
}
} }
} }

View File

@ -50,15 +50,18 @@ where
F: Fn(&O) -> bool, F: Fn(&O) -> bool,
{ {
let orig_rep = parser.representation(); let orig_rep = parser.representation();
(move |input| { (
parser.parse(input).and_then(|(result, rest)| { move |input| {
if pred_fn(&result) { parser.parse(input).and_then(|(result, rest)| {
Ok((result, rest)) if pred_fn(&result) {
} else { Ok((result, rest))
Err(rest) } else {
} Err(rest)
}) }
}, Representation::new(&format!("{:?} if <PREDICATE>", orig_rep))) })
},
Representation::new(&format!("{:?} if <PREDICATE>", orig_rep)),
)
} }
/// Parses a standard identifier in a programming language /// Parses a standard identifier in a programming language