pub struct StrictlyNegative;Expand description
Marker type enforcing that a value is strictly negative (less than zero).
Use this type with Constrained<T, StrictlyNegative> to encode strict
negativity at the type level.
You can construct a value constrained to be strictly negative using
either the generic Constrained::new method or the convenient
StrictlyNegative::new associated function.
§Examples
use twine_core::constraint::{Constrained, StrictlyNegative};
// Generic constructor:
let x = Constrained::<_, StrictlyNegative>::new(-1).unwrap();
assert_eq!(x.into_inner(), -1);
// Associated constructor:
let y = StrictlyNegative::new(-2.5).unwrap();
assert_eq!(y.into_inner(), -2.5);
// Error cases:
assert!(StrictlyNegative::new(0).is_err());
assert!(StrictlyNegative::new(3).is_err());
assert!(StrictlyNegative::new(f64::NAN).is_err());Implementations§
Source§impl StrictlyNegative
impl StrictlyNegative
Sourcepub fn new<T: PartialOrd + Zero>(
value: T,
) -> Result<Constrained<T, StrictlyNegative>, ConstraintError>
pub fn new<T: PartialOrd + Zero>( value: T, ) -> Result<Constrained<T, StrictlyNegative>, ConstraintError>
Constructs a Constrained<T, StrictlyNegative> if the value is strictly negative.
§Errors
Returns an error if the value is zero, positive, or not a number (NaN).
Trait Implementations§
Source§impl Clone for StrictlyNegative
impl Clone for StrictlyNegative
Source§fn clone(&self) -> StrictlyNegative
fn clone(&self) -> StrictlyNegative
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: PartialOrd + Zero> Constraint<T> for StrictlyNegative
impl<T: PartialOrd + Zero> Constraint<T> for StrictlyNegative
Source§impl Debug for StrictlyNegative
impl Debug for StrictlyNegative
Source§impl PartialEq for StrictlyNegative
impl PartialEq for StrictlyNegative
impl Copy for StrictlyNegative
impl Eq for StrictlyNegative
impl StructuralPartialEq for StrictlyNegative
Auto Trait Implementations§
impl Freeze for StrictlyNegative
impl RefUnwindSafe for StrictlyNegative
impl Send for StrictlyNegative
impl Sync for StrictlyNegative
impl Unpin for StrictlyNegative
impl UnwindSafe for StrictlyNegative
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.