Skip to content

Commit

Permalink
feat: derive Default for Stateful/Recoverable
Browse files Browse the repository at this point in the history
Signed-off-by: TennyZhuang <zty0826@gmail.com>
  • Loading branch information
TennyZhuang committed May 23, 2024
1 parent 1096fb1 commit 789f6c1
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 789f6c1

Please sign in to comment.