Skip to content

Commit

Permalink
Merge pull request #525 from TennyZhuang/derive-default-stateful
Browse files Browse the repository at this point in the history
feat: derive Default for (Stateful|Recoverable)
  • Loading branch information
epage committed May 28, 2024
2 parents f349369 + 789f6c1 commit 99cbbd9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ where
is_recoverable: bool,
}

#[cfg(feature = "unstable-recover")]
#[cfg(feature = "std")]
impl<I, E> Default for Recoverable<I, E>
where
I: Default + Stream,
{
fn default() -> Self {
Self::new(I::default())
}
}

#[cfg(feature = "unstable-recover")]
#[cfg(feature = "std")]
impl<I, E> Recoverable<I, E>
Expand Down Expand Up @@ -298,7 +309,7 @@ impl<I: Stream + crate::lib::std::fmt::Debug, E: crate::lib::std::fmt::Debug>
/// let output = word.parse(input).unwrap();
/// assert_eq!(state.get(), 1);
/// ```
#[derive(Clone, Copy, Eq, PartialEq)]
#[derive(Clone, Copy, Default, Eq, PartialEq)]
#[doc(alias = "LocatedSpan")]
pub struct Stateful<I, S> {
/// Inner input being wrapped in state
Expand Down

0 comments on commit 99cbbd9

Please sign in to comment.