Skip to content

Commit 65d54d8

Browse files
authored
Merge pull request #210 from scanner-inc/arbitrary-for-cmp-reverse
Implement Arbitrary for core::cmp::Reverse
2 parents 893f654 + 05de6a5 commit 65d54d8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/foreign/core/cmp.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use {
2+
crate::{size_hint, Arbitrary, Result, Unstructured},
3+
core::cmp::Reverse,
4+
};
5+
6+
impl<'a, A> Arbitrary<'a> for Reverse<A>
7+
where
8+
A: Arbitrary<'a>,
9+
{
10+
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
11+
Arbitrary::arbitrary(u).map(Self)
12+
}
13+
14+
#[inline]
15+
fn size_hint(depth: usize) -> (usize, Option<usize>) {
16+
Self::try_size_hint(depth).unwrap_or_default()
17+
}
18+
19+
#[inline]
20+
fn try_size_hint(depth: usize) -> Result<(usize, Option<usize>), crate::MaxRecursionReached> {
21+
size_hint::try_recursion_guard(depth, <A as Arbitrary>::try_size_hint)
22+
}
23+
}

src/foreign/core/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod array;
66
mod bool;
77
mod cell;
88
mod char;
9+
mod cmp;
910
mod iter;
1011
mod marker;
1112
mod num;

0 commit comments

Comments
 (0)