From 1e3dadd45866d2e2888ad99ffb231d1d4099e940 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 22 Aug 2023 17:24:26 -0400 Subject: [PATCH] Wrap the input. --- src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 63db4e14..b6359e2f 100644 --- a/src/main.rs +++ b/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 } + } +}