Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
c410-f3r committed Nov 1, 2024
1 parent 9dc899e commit 9ea8986
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions library/kani_core/src/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ macro_rules! generate_arbitrary {
T: Arbitrary,
{
fn any() -> Self {
match u8::any() % 3 {
match u8::any() {
0 => Bound::Included(T::any()),
1 => Bound::Excluded(T::any()),
_ => Bound::Unbounded,
Expand All @@ -218,12 +218,10 @@ macro_rules! generate_arbitrary {

impl<T> Arbitrary for Range<T>
where
T: Arbitrary + PartialOrd,
T: Arbitrary,
{
fn any() -> Self {
let (mut first, mut second) = (T::any(), T::any());
adjust(&mut first, &mut second);
first..second
T::any()..T::any()
}
}

Expand All @@ -238,12 +236,10 @@ macro_rules! generate_arbitrary {

impl<T> Arbitrary for RangeInclusive<T>
where
T: Arbitrary + PartialOrd,
T: Arbitrary,
{
fn any() -> Self {
let (mut first, mut second) = (T::any(), T::any());
adjust(&mut first, &mut second);
first..=second
T::any()..=T::any()
}
}

Expand All @@ -264,15 +260,6 @@ macro_rules! generate_arbitrary {
..=T::any()
}
}

fn adjust<T>(first: &mut T, second: &mut T)
where
T: PartialOrd,
{
if first > second {
mem::swap(first, second);
}
}
}
};
}
Expand Down

0 comments on commit 9ea8986

Please sign in to comment.