Wrap the input.

This commit is contained in:
Tom Alexander 2023-08-22 17:24:26 -04:00
parent 2ec055af5a
commit 1e3dadd458
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -2,12 +2,20 @@ use nom::bytes::complete::tag;
fn main() {
let input = "this is my test input".to_owned();
let wrapped_input = WrappedInput::new(input.as_str());
let output = tag::<_, _, (_, nom::error::ErrorKind)>("this")(input.as_str()).unwrap();
let output = tag::<_, _, (_, nom::error::ErrorKind)>("this")(wrapped_input).unwrap();
println!("{:#?}", output);
}
#[derive(Debug)]
struct WrappedInput<'s> {
contents: &'s str,
}
impl<'s> WrappedInput<'s> {
pub fn new(input: &'s str) -> Self {
WrappedInput { contents: input }
}
}