Wrap the input.
This commit is contained in:
parent
2ec055af5a
commit
1e3dadd458
10
src/main.rs
10
src/main.rs
@ -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 }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user