pub struct SizeRange(/* private fields */);
Expand description
The minimum and maximum range/bounds on the size of a collection.
The interval must form a subset of [0, std::usize::MAX)
.
A value like 0..=std::usize::MAX
will still be accepted but will silently
truncate the maximum to std::usize::MAX - 1
.
The Default
is 0..PROPTEST_MAX_DEFAULT_SIZE_RANGE
. The max can be set with
the PROPTEST_MAX_DEFAULT_SIZE_RANGE
env var, which defaults to 100
.
Implementations§
Source§impl SizeRange
impl SizeRange
Sourcepub fn new(range: RangeInclusive<usize>) -> Self
pub fn new(range: RangeInclusive<usize>) -> Self
Creates a SizeBounds
from a RangeInclusive<usize>
.
Sourcepub fn with<X>(self, and: X) -> (Self, X)
pub fn with<X>(self, and: X) -> (Self, X)
Merges self together with some other argument producing a product
type expected by some implementations of A: Arbitrary
in
A::Parameters
. This can be more ergonomic to work with and may
help type inference.
Sourcepub fn lift<X: Default>(self) -> (Self, X)
pub fn lift<X: Default>(self) -> (Self, X)
Merges self together with some other argument generated with a
default value producing a product type expected by some
implementations of A: Arbitrary
in A::Parameters
.
This can be more ergonomic to work with and may help type inference.
Sourcepub fn start_end_incl(&self) -> (usize, usize)
pub fn start_end_incl(&self) -> (usize, usize)
Extract the ends [low, high]
of a SizeRange
.
Trait Implementations§
Source§impl Add<usize> for SizeRange
impl Add<usize> for SizeRange
Adds usize
to both start and end of the bounds.
Panics if adding to either end overflows usize
.
Source§impl Arbitrary for SizeRange
impl Arbitrary for SizeRange
Source§type Parameters = ()
type Parameters = ()
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.Source§type Strategy = MapInto<<RangeInclusive<usize> as Arbitrary>::Strategy, SizeRange>
type Strategy = MapInto<<RangeInclusive<usize> as Arbitrary>::Strategy, SizeRange>
Strategy
used to generate values of type Self
.Source§fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy
Source§impl From<(usize, usize)> for SizeRange
impl From<(usize, usize)> for SizeRange
Given (low: usize, high: usize)
,
then a size range of [low..high)
is the result.
Source§impl From<Range<usize>> for SizeRange
impl From<Range<usize>> for SizeRange
Given low .. high
, then a size range [low, high)
is the result.
Source§impl From<RangeInclusive<usize>> for SizeRange
impl From<RangeInclusive<usize>> for SizeRange
Given low ..= high
, then a size range [low, high]
is the result.
Source§fn from(r: RangeInclusive<usize>) -> Self
fn from(r: RangeInclusive<usize>) -> Self
Source§impl From<RangeTo<usize>> for SizeRange
impl From<RangeTo<usize>> for SizeRange
Given ..high
, then a size range [0, high)
is the result.
Source§impl From<RangeToInclusive<usize>> for SizeRange
impl From<RangeToInclusive<usize>> for SizeRange
Given ..=high
, then a size range [0, high]
is the result.
Source§fn from(high: RangeToInclusive<usize>) -> Self
fn from(high: RangeToInclusive<usize>) -> Self
Source§impl From<usize> for SizeRange
impl From<usize> for SizeRange
Given exact
, then a size range of [exact, exact]
is the result.