From 3077bb0d0450f229d5e960be0f5aca0bca630364 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 19 Jul 2024 09:58:48 -0500 Subject: [PATCH 1/2] fix(parse): Remove unneeded Clone bound for Parser::parse --- src/parser.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/parser.rs b/src/parser.rs index ceda7435..63fb2312 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -54,7 +54,6 @@ pub trait Parser { I: Stream, // Force users to deal with `Incomplete` when `StreamIsPartial` I: StreamIsPartial, - I: Clone, E: ParserError, { debug_assert!( From 57bd58251d93fc9c597dd60c16b01d75585b9b17 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 19 Jul 2024 09:58:59 -0500 Subject: [PATCH 2/2] docs(stream): Remove Stateful's use of cell This isn't needed with the new `&mut I` API as of 0.5 --- src/stream/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/stream/mod.rs b/src/stream/mod.rs index 452e2179..3073e966 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -287,12 +287,12 @@ impl /// # use winnow::ascii::alpha1; /// # type Error = (); /// -/// #[derive(Clone, Debug)] -/// struct State<'s>(&'s Cell); +/// #[derive(Debug)] +/// struct State<'s>(&'s mut u32); /// /// impl<'s> State<'s> { -/// fn count(&self) { -/// self.0.set(self.0.get() + 1); +/// fn count(&mut self) { +/// *self.0 += 1; /// } /// } /// @@ -304,10 +304,10 @@ impl /// } /// /// let data = "Hello"; -/// let state = Cell::new(0); -/// let input = Stream { input: data, state: State(&state) }; +/// let mut state = 0; +/// let input = Stream { input: data, state: State(&mut state) }; /// let output = word.parse(input).unwrap(); -/// assert_eq!(state.get(), 1); +/// assert_eq!(state, 1); /// ``` #[derive(Clone, Copy, Default, Eq, PartialEq)] #[doc(alias = "LocatedSpan")]