devela::all

Trait NumRef

Source
pub trait NumRef<'a>
where Self: Deref<Target = Self::Own>,
{ type Own: Num;
Show 21 methods // Provided methods fn num_to_owned(&self) -> Result<Self::Own> where Self::Own: Clone { ... } fn num_set(&mut self, value: <Self::Own as Num>::Inner) -> Result<()> where Self: DerefMut<Target = Self::Own> { ... } fn num_set_ref(&mut self, value: &<Self::Own as Num>::Inner) -> Result<()> where Self: DerefMut<Target = Self::Own> { ... } fn num_is_zero(&self) -> Result<bool> { ... } fn num_get_zero() -> Result<Self::Own> { ... } fn num_set_zero(&mut self) -> Result<()> where Self: DerefMut<Target = Self::Own> { ... } fn num_is_one(&self) -> Result<bool> { ... } fn num_get_one() -> Result<Self::Own> { ... } fn num_set_one(&mut self) -> Result<()> where Self: DerefMut<Target = Self::Own> { ... } fn num_ref_add( &self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<<Self::Own as Num>::Out> { ... } fn num_ref_add_assign( &mut self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<()> where Self: DerefMut<Target = Self::Own> { ... } fn num_ref_sub( &self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<<Self::Own as Num>::Out> { ... } fn num_ref_sub_assign( &mut self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<()> where Self: DerefMut<Target = Self::Own> { ... } fn num_ref_mul( &self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<<Self::Own as Num>::Out> { ... } fn num_ref_mul_assign( &mut self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<()> where Self: DerefMut<Target = Self::Own> { ... } fn num_ref_div( &self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<<Self::Own as Num>::Out> { ... } fn num_ref_div_assign( &mut self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<()> where Self: DerefMut<Target = Self::Own> { ... } fn num_ref_rem( &self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<<Self::Own as Num>::Out> { ... } fn num_ref_rem_assign( &mut self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<()> where Self: DerefMut<Target = Self::Own> { ... } fn num_ref_neg(&self) -> Result<<Self::Own as Num>::Out> { ... } fn num_ref_abs(&self) -> Result<<Self::Own as Num>::Out> { ... }
}
Expand description

Common auto-trait for referenced numeric types.

It is automatically implemented for references of types implementing Num. Mutable operations are only available for exclusive (&mut) references.

Required Associated Types§

Source

type Own: Num

The owned version of this numeric type.

Provided Methods§

Source

fn num_to_owned(&self) -> Result<Self::Own>
where Self::Own: Clone,

Returns the owned version of self, if it can be cloned.

Source

fn num_set(&mut self, value: <Self::Own as Num>::Inner) -> Result<()>
where Self: DerefMut<Target = Self::Own>,

Sets self to a valid value.

Source

fn num_set_ref(&mut self, value: &<Self::Own as Num>::Inner) -> Result<()>
where Self: DerefMut<Target = Self::Own>,

Sets self to a valid &value.

Source

fn num_is_zero(&self) -> Result<bool>

Returns true if self is zero.

Source

fn num_get_zero() -> Result<Self::Own>

Returns the number zero.

Source

fn num_set_zero(&mut self) -> Result<()>
where Self: DerefMut<Target = Self::Own>,

Sets self to zero.

Source

fn num_is_one(&self) -> Result<bool>

Returns true if self is one.

Source

fn num_get_one() -> Result<Self::Own>

Returns the number one.

Source

fn num_set_one(&mut self) -> Result<()>
where Self: DerefMut<Target = Self::Own>,

Sets the number to one.

Source

fn num_ref_add( &self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<<Self::Own as Num>::Out>

Computes &self + &rhs.

Source

fn num_ref_add_assign(&mut self, rhs: &<Self::Own as Num>::Rhs) -> Result<()>
where Self: DerefMut<Target = Self::Own>,

Computes &mut self += &rhs.

Source

fn num_ref_sub( &self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<<Self::Own as Num>::Out>

Computes &self - &rhs.

Source

fn num_ref_sub_assign(&mut self, rhs: &<Self::Own as Num>::Rhs) -> Result<()>
where Self: DerefMut<Target = Self::Own>,

Computes &mut self -= &rhs.

Source

fn num_ref_mul( &self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<<Self::Own as Num>::Out>

Computes &self * &rhs.

Source

fn num_ref_mul_assign(&mut self, rhs: &<Self::Own as Num>::Rhs) -> Result<()>
where Self: DerefMut<Target = Self::Own>,

Computes &mut self *= &rhs.

Source

fn num_ref_div( &self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<<Self::Own as Num>::Out>

Computes &self / &rhs.

Source

fn num_ref_div_assign(&mut self, rhs: &<Self::Own as Num>::Rhs) -> Result<()>
where Self: DerefMut<Target = Self::Own>,

Computes &mut self /= &rhs.

Source

fn num_ref_rem( &self, rhs: &<Self::Own as Num>::Rhs, ) -> Result<<Self::Own as Num>::Out>

Computes &self % &rhs.

Source

fn num_ref_rem_assign(&mut self, rhs: &<Self::Own as Num>::Rhs) -> Result<()>
where Self: DerefMut<Target = Self::Own>,

Computes &mut self %= &rhs.

Source

fn num_ref_neg(&self) -> Result<<Self::Own as Num>::Out>

Computes - &self.

Source

fn num_ref_abs(&self) -> Result<<Self::Own as Num>::Out>

Computes the absolute value of &self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: Num> NumRef<'_> for &T

Source§

type Own = T

Source§

impl<T: Num> NumRef<'_> for &mut T

Source§

type Own = T

Implementors§