Skip to content

Commit

Permalink
Merge pull request #566 from epage/stateful
Browse files Browse the repository at this point in the history
docs(stream): Remove Stateful's use of cell
  • Loading branch information
epage authored Jul 19, 2024
2 parents afb5b65 + 57bd582 commit 823f627
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ pub trait Parser<I, O, E> {
I: Stream,
// Force users to deal with `Incomplete` when `StreamIsPartial<true>`
I: StreamIsPartial,
I: Clone,
E: ParserError<I>,
{
debug_assert!(
Expand Down
14 changes: 7 additions & 7 deletions src/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,12 @@ impl<I: Stream + crate::lib::std::fmt::Debug, E: crate::lib::std::fmt::Debug>
/// # use winnow::ascii::alpha1;
/// # type Error = ();
///
/// #[derive(Clone, Debug)]
/// struct State<'s>(&'s Cell<u32>);
/// #[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;
/// }
/// }
///
Expand All @@ -304,10 +304,10 @@ impl<I: Stream + crate::lib::std::fmt::Debug, E: crate::lib::std::fmt::Debug>
/// }
///
/// 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")]
Expand Down

0 comments on commit 823f627

Please sign in to comment.