From b2dbcf3168555e0e12656c3094ab22e10dd7a77a Mon Sep 17 00:00:00 2001 From: Andreas Longva Date: Wed, 20 Jan 2021 17:42:25 +0100 Subject: [PATCH] Add D=Dynamic default and ::to_range_inclusive for DimRange (nalgebra) --- src/proptest/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/proptest/mod.rs b/src/proptest/mod.rs index 093e1525..56c0f9cf 100644 --- a/src/proptest/mod.rs +++ b/src/proptest/mod.rs @@ -169,7 +169,7 @@ pub struct MatrixParameters { /// ranges such as `5 ..= 6`. The latter example corresponds to dimensions from (inclusive) /// `Dynamic::new(5)` to `Dynamic::new(6)` (inclusive). #[derive(Debug, Clone, PartialEq, Eq)] -pub struct DimRange(RangeInclusive); +pub struct DimRange(RangeInclusive); impl DimRange { /// The lower bound for dimensions generated. @@ -201,6 +201,13 @@ impl From> for DimRange { } } +impl DimRange { + /// Converts the `DimRange` into an instance of `RangeInclusive`. + pub fn to_range_inclusive(&self) -> RangeInclusive { + self.lower_bound().value() ..= self.upper_bound().value() + } +} + impl From for DimRange { fn from(dim: usize) -> Self { DimRange::from(Dynamic::new(dim))