Skip to content

Commit

Permalink
Make MaxRecursionReached error possible to evolve in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Sep 18, 2024
1 parent e5897a1 commit b6991ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ pub use derive_arbitrary::*;
pub use unstructured::Unstructured;

/// Error indicating that the maximum recursion depth has been reached while calculating [`Arbitrary::size_hint`]()
#[derive(Debug, Clone, Copy)]
pub struct MaxRecursionReached;
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct MaxRecursionReached {}

impl core::fmt::Display for MaxRecursionReached {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion src/size_hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn try_recursion_guard(
f: impl FnOnce(usize) -> Result<(usize, Option<usize>), crate::MaxRecursionReached>,
) -> Result<(usize, Option<usize>), crate::MaxRecursionReached> {
if depth > MAX_DEPTH {
Err(crate::MaxRecursionReached)
Err(crate::MaxRecursionReached {})
} else {
f(depth + 1)
}
Expand Down

0 comments on commit b6991ce

Please sign in to comment.