pub trait RoundToMultipleAssign<RHS = Self> {
    fn round_to_multiple_assign(&mut self, other: RHS, rm: RoundingMode);
}
Expand description

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

Required Methods

Implementations on Foreign Types

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding modes that are guaranteed to return without a panic are Down and Floor.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding modes that are guaranteed to return without a panic are Down and Floor.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding modes that are guaranteed to return without a panic are Down and Floor.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding modes that are guaranteed to return without a panic are Down and Floor.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding modes that are guaranteed to return without a panic are Down and Floor.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding modes that are guaranteed to return without a panic are Down and Floor.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding mode that is guaranteed to return without a panic is Down.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding mode that is guaranteed to return without a panic is Down.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding mode that is guaranteed to return without a panic is Down.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding mode that is guaranteed to return without a panic is Down.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding mode that is guaranteed to return without a panic is Down.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Rounds a number to a multiple of another number in place, according to a specified rounding mode.

The only rounding mode that is guaranteed to return without a panic is Down.

See the RoundToMultiple documentation for details.

The following two expressions are equivalent:

  • x.round_to_multiple_assign(other, RoundingMode::Exact);
  • assert!(x.divisible_by(other));

but the latter should be used as it is clearer and more efficient.

Worst-case complexity

Constant time and additional memory.

Panics
  • If rm is Exact, but self is not a multiple of other.
  • If the multiple is outside the representable range.
  • If self is nonzero, other is zero, and rm is trying to round away from zero.
Examples

See here.

Implementors