pub struct NonNegative { /* private fields */ }Expand description
NonNegative, a wrapper for a f64 value, ensuring it is always >= 0
Implementations§
Source§impl NonNegative
impl NonNegative
Sourcepub fn new(val: f64) -> Result<NonNegative>
pub fn new(val: f64) -> Result<NonNegative>
Creates a new NonNegative if input >= 0, fails otherwise
Sourcepub fn zero() -> NonNegative
pub fn zero() -> NonNegative
Creates a new NonNegative with value 0
Sourcepub fn one() -> NonNegative
pub fn one() -> NonNegative
Creates a new NonNegative with value 1
Sourcepub fn sqrt(&self) -> NonNegative
pub fn sqrt(&self) -> NonNegative
Returns the square root
Trait Implementations§
Source§impl Add for NonNegative
impl Add for NonNegative
Source§type Output = NonNegative
type Output = NonNegative
The resulting type after applying the
+ operator.Source§fn add(self, other: NonNegative) -> NonNegative
fn add(self, other: NonNegative) -> NonNegative
Performs the
+ operation. Read moreSource§impl Add<NonNegative> for Positive
impl Add<NonNegative> for Positive
Source§impl Add<Positive> for NonNegative
impl Add<Positive> for NonNegative
Source§type Output = NonNegative
type Output = NonNegative
The resulting type after applying the
+ operator.Source§impl AddAssign for NonNegative
impl AddAssign for NonNegative
Source§fn add_assign(&mut self, other: NonNegative)
fn add_assign(&mut self, other: NonNegative)
Performs the
+= operation. Read moreSource§impl AddAssign<NonNegative> for Positive
impl AddAssign<NonNegative> for Positive
Source§fn add_assign(&mut self, other: NonNegative)
fn add_assign(&mut self, other: NonNegative)
Performs the
+= operation. Read moreSource§impl AddAssign<Positive> for NonNegative
impl AddAssign<Positive> for NonNegative
Source§fn add_assign(&mut self, other: Positive)
fn add_assign(&mut self, other: Positive)
Performs the
+= operation. Read moreSource§impl AsRef<f64> for NonNegative
impl AsRef<f64> for NonNegative
Source§impl Clone for NonNegative
impl Clone for NonNegative
Source§fn clone(&self) -> NonNegative
fn clone(&self) -> NonNegative
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for NonNegative
Source§impl Debug for NonNegative
impl Debug for NonNegative
Source§impl Default for NonNegative
impl Default for NonNegative
Source§impl Display for NonNegative
impl Display for NonNegative
Source§impl Div for NonNegative
impl Div for NonNegative
Source§type Output = NonNegative
type Output = NonNegative
The resulting type after applying the
/ operator.Source§fn div(self, other: NonNegative) -> NonNegative
fn div(self, other: NonNegative) -> NonNegative
Performs the
/ operation. Read moreSource§impl Div<NonNegative> for Positive
impl Div<NonNegative> for Positive
Source§type Output = NonNegative
type Output = NonNegative
The resulting type after applying the
/ operator.Source§fn div(self, other: NonNegative) -> NonNegative
fn div(self, other: NonNegative) -> NonNegative
Performs the
/ operation. Read moreSource§impl Div<Positive> for NonNegative
impl Div<Positive> for NonNegative
Source§type Output = NonNegative
type Output = NonNegative
The resulting type after applying the
/ operator.Source§impl DivAssign for NonNegative
impl DivAssign for NonNegative
Source§fn div_assign(&mut self, other: NonNegative)
fn div_assign(&mut self, other: NonNegative)
Performs the
/= operation. Read moreSource§impl DivAssign<Positive> for NonNegative
impl DivAssign<Positive> for NonNegative
Source§fn div_assign(&mut self, other: Positive)
fn div_assign(&mut self, other: Positive)
Performs the
/= operation. Read moreimpl Eq for NonNegative
Source§impl From<Positive> for NonNegative
impl From<Positive> for NonNegative
Source§impl Hash for NonNegative
impl Hash for NonNegative
Source§impl Into<f64> for NonNegative
impl Into<f64> for NonNegative
Source§impl Mul for NonNegative
impl Mul for NonNegative
Source§type Output = NonNegative
type Output = NonNegative
The resulting type after applying the
* operator.Source§fn mul(self, other: NonNegative) -> NonNegative
fn mul(self, other: NonNegative) -> NonNegative
Performs the
* operation. Read moreSource§impl Mul<NonNegative> for Positive
impl Mul<NonNegative> for Positive
Source§type Output = NonNegative
type Output = NonNegative
The resulting type after applying the
* operator.Source§fn mul(self, other: NonNegative) -> NonNegative
fn mul(self, other: NonNegative) -> NonNegative
Performs the
* operation. Read moreSource§impl Mul<Positive> for NonNegative
impl Mul<Positive> for NonNegative
Source§type Output = NonNegative
type Output = NonNegative
The resulting type after applying the
* operator.Source§impl MulAssign for NonNegative
impl MulAssign for NonNegative
Source§fn mul_assign(&mut self, other: NonNegative)
fn mul_assign(&mut self, other: NonNegative)
Performs the
*= operation. Read moreSource§impl MulAssign<Positive> for NonNegative
impl MulAssign<Positive> for NonNegative
Source§fn mul_assign(&mut self, other: Positive)
fn mul_assign(&mut self, other: Positive)
Performs the
*= operation. Read moreSource§impl PartialEq for NonNegative
impl PartialEq for NonNegative
Source§fn eq(&self, other: &NonNegative) -> bool
fn eq(&self, other: &NonNegative) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for NonNegative
impl PartialOrd for NonNegative
impl StructuralPartialEq for NonNegative
Auto Trait Implementations§
impl Freeze for NonNegative
impl RefUnwindSafe for NonNegative
impl Send for NonNegative
impl Sync for NonNegative
impl Unpin for NonNegative
impl UnsafeUnpin for NonNegative
impl UnwindSafe for NonNegative
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more