pub trait SaturatingFrom<T>: Sized {
    // Required method
    fn saturating_from(value: T) -> Self;
}
Expand description

Converts a value from one type to another, where if the conversion is not exact the result is set to the maximum or minimum value of the result type, whichever is closer.

Required Methods§

source

fn saturating_from(value: T) -> Self

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl SaturatingFrom<i8> for i8

source§

fn saturating_from(value: i8) -> i8

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i8> for i16

source§

fn saturating_from(value: i8) -> i16

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i8> for i32

source§

fn saturating_from(value: i8) -> i32

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i8> for i64

source§

fn saturating_from(value: i8) -> i64

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i8> for i128

source§

fn saturating_from(value: i8) -> i128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i8> for isize

source§

fn saturating_from(value: i8) -> isize

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i8> for u8

source§

fn saturating_from(value: i8) -> u8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i8> for u16

source§

fn saturating_from(value: i8) -> u16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i8> for u32

source§

fn saturating_from(value: i8) -> u32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i8> for u64

source§

fn saturating_from(value: i8) -> u64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i8> for u128

source§

fn saturating_from(value: i8) -> u128

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i8> for usize

source§

fn saturating_from(value: i8) -> usize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for i8

source§

fn saturating_from(value: i16) -> i8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for i16

source§

fn saturating_from(value: i16) -> i16

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for i32

source§

fn saturating_from(value: i16) -> i32

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for i64

source§

fn saturating_from(value: i16) -> i64

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for i128

source§

fn saturating_from(value: i16) -> i128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for isize

source§

fn saturating_from(value: i16) -> isize

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for u8

source§

fn saturating_from(value: i16) -> u8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for u16

source§

fn saturating_from(value: i16) -> u16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for u32

source§

fn saturating_from(value: i16) -> u32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for u64

source§

fn saturating_from(value: i16) -> u64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for u128

source§

fn saturating_from(value: i16) -> u128

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i16> for usize

source§

fn saturating_from(value: i16) -> usize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for i8

source§

fn saturating_from(value: i32) -> i8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for i16

source§

fn saturating_from(value: i32) -> i16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for i32

source§

fn saturating_from(value: i32) -> i32

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for i64

source§

fn saturating_from(value: i32) -> i64

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for i128

source§

fn saturating_from(value: i32) -> i128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for isize

source§

fn saturating_from(value: i32) -> isize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for u8

source§

fn saturating_from(value: i32) -> u8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for u16

source§

fn saturating_from(value: i32) -> u16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for u32

source§

fn saturating_from(value: i32) -> u32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for u64

source§

fn saturating_from(value: i32) -> u64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for u128

source§

fn saturating_from(value: i32) -> u128

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i32> for usize

source§

fn saturating_from(value: i32) -> usize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for i8

source§

fn saturating_from(value: i64) -> i8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for i16

source§

fn saturating_from(value: i64) -> i16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for i32

source§

fn saturating_from(value: i64) -> i32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for i64

source§

fn saturating_from(value: i64) -> i64

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for i128

source§

fn saturating_from(value: i64) -> i128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for isize

source§

fn saturating_from(value: i64) -> isize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for u8

source§

fn saturating_from(value: i64) -> u8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for u16

source§

fn saturating_from(value: i64) -> u16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for u32

source§

fn saturating_from(value: i64) -> u32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for u64

source§

fn saturating_from(value: i64) -> u64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for u128

source§

fn saturating_from(value: i64) -> u128

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i64> for usize

source§

fn saturating_from(value: i64) -> usize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for i8

source§

fn saturating_from(value: i128) -> i8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for i16

source§

fn saturating_from(value: i128) -> i16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for i32

source§

fn saturating_from(value: i128) -> i32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for i64

source§

fn saturating_from(value: i128) -> i64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for i128

source§

fn saturating_from(value: i128) -> i128

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for isize

source§

fn saturating_from(value: i128) -> isize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for u8

source§

fn saturating_from(value: i128) -> u8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for u16

source§

fn saturating_from(value: i128) -> u16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for u32

source§

fn saturating_from(value: i128) -> u32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for u64

source§

fn saturating_from(value: i128) -> u64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for u128

source§

fn saturating_from(value: i128) -> u128

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<i128> for usize

source§

fn saturating_from(value: i128) -> usize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for i8

source§

fn saturating_from(value: isize) -> i8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for i16

source§

fn saturating_from(value: isize) -> i16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for i32

source§

fn saturating_from(value: isize) -> i32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for i64

source§

fn saturating_from(value: isize) -> i64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for i128

source§

fn saturating_from(value: isize) -> i128

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for isize

source§

fn saturating_from(value: isize) -> isize

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for u8

source§

fn saturating_from(value: isize) -> u8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for u16

source§

fn saturating_from(value: isize) -> u16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for u32

source§

fn saturating_from(value: isize) -> u32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for u64

source§

fn saturating_from(value: isize) -> u64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for u128

source§

fn saturating_from(value: isize) -> u128

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<isize> for usize

source§

fn saturating_from(value: isize) -> usize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for i8

source§

fn saturating_from(value: u8) -> i8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for i16

source§

fn saturating_from(value: u8) -> i16

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for i32

source§

fn saturating_from(value: u8) -> i32

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for i64

source§

fn saturating_from(value: u8) -> i64

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for i128

source§

fn saturating_from(value: u8) -> i128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for isize

source§

fn saturating_from(value: u8) -> isize

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for u8

source§

fn saturating_from(value: u8) -> u8

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for u16

source§

fn saturating_from(value: u8) -> u16

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for u32

source§

fn saturating_from(value: u8) -> u32

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for u64

source§

fn saturating_from(value: u8) -> u64

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for u128

source§

fn saturating_from(value: u8) -> u128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u8> for usize

source§

fn saturating_from(value: u8) -> usize

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for i8

source§

fn saturating_from(value: u16) -> i8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for i16

source§

fn saturating_from(value: u16) -> i16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for i32

source§

fn saturating_from(value: u16) -> i32

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for i64

source§

fn saturating_from(value: u16) -> i64

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for i128

source§

fn saturating_from(value: u16) -> i128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for isize

source§

fn saturating_from(value: u16) -> isize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for u8

source§

fn saturating_from(value: u16) -> u8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for u16

source§

fn saturating_from(value: u16) -> u16

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for u32

source§

fn saturating_from(value: u16) -> u32

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for u64

source§

fn saturating_from(value: u16) -> u64

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for u128

source§

fn saturating_from(value: u16) -> u128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u16> for usize

source§

fn saturating_from(value: u16) -> usize

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for i8

source§

fn saturating_from(value: u32) -> i8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for i16

source§

fn saturating_from(value: u32) -> i16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for i32

source§

fn saturating_from(value: u32) -> i32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for i64

source§

fn saturating_from(value: u32) -> i64

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for i128

source§

fn saturating_from(value: u32) -> i128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for isize

source§

fn saturating_from(value: u32) -> isize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for u8

source§

fn saturating_from(value: u32) -> u8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for u16

source§

fn saturating_from(value: u32) -> u16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for u32

source§

fn saturating_from(value: u32) -> u32

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for u64

source§

fn saturating_from(value: u32) -> u64

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for u128

source§

fn saturating_from(value: u32) -> u128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u32> for usize

source§

fn saturating_from(value: u32) -> usize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for i8

source§

fn saturating_from(value: u64) -> i8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for i16

source§

fn saturating_from(value: u64) -> i16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for i32

source§

fn saturating_from(value: u64) -> i32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for i64

source§

fn saturating_from(value: u64) -> i64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for i128

source§

fn saturating_from(value: u64) -> i128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for isize

source§

fn saturating_from(value: u64) -> isize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for u8

source§

fn saturating_from(value: u64) -> u8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for u16

source§

fn saturating_from(value: u64) -> u16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for u32

source§

fn saturating_from(value: u64) -> u32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for u64

source§

fn saturating_from(value: u64) -> u64

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for u128

source§

fn saturating_from(value: u64) -> u128

Converts a value to another type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u64> for usize

source§

fn saturating_from(value: u64) -> usize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for i8

source§

fn saturating_from(value: u128) -> i8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for i16

source§

fn saturating_from(value: u128) -> i16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for i32

source§

fn saturating_from(value: u128) -> i32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for i64

source§

fn saturating_from(value: u128) -> i64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for i128

source§

fn saturating_from(value: u128) -> i128

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for isize

source§

fn saturating_from(value: u128) -> isize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for u8

source§

fn saturating_from(value: u128) -> u8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for u16

source§

fn saturating_from(value: u128) -> u16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for u32

source§

fn saturating_from(value: u128) -> u32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for u64

source§

fn saturating_from(value: u128) -> u64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for u128

source§

fn saturating_from(value: u128) -> u128

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<u128> for usize

source§

fn saturating_from(value: u128) -> usize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for i8

source§

fn saturating_from(value: usize) -> i8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for i16

source§

fn saturating_from(value: usize) -> i16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for i32

source§

fn saturating_from(value: usize) -> i32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for i64

source§

fn saturating_from(value: usize) -> i64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for i128

source§

fn saturating_from(value: usize) -> i128

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for isize

source§

fn saturating_from(value: usize) -> isize

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for u8

source§

fn saturating_from(value: usize) -> u8

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for u16

source§

fn saturating_from(value: usize) -> u16

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for u32

source§

fn saturating_from(value: usize) -> u32

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for u64

source§

fn saturating_from(value: usize) -> u64

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for u128

source§

fn saturating_from(value: usize) -> u128

Converts a value to another type. If the value cannot be represented in the new type, the maximum or minimum value of the new type, whichever is closer, is returned.

Let $W$ be the width of the target type.

If the target type is unsigned, then $$ f_W(n) = \begin{cases} 0 & n < 0 \\ 2^W-1 & \text{if} \quad n \geq 2^W, \\ n & \text{otherwise}. \end{cases} $$

If the target type is signed, then $$ f_W(n) = \begin{cases} -2^{W-1} & \text{if} \quad n < -2^{W-1}, \\ 2^{W-1}-1 & \text{if} \quad n \geq 2^{W-1}, \\ n & \text{otherwise}. \end{cases} $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl SaturatingFrom<usize> for usize

source§

fn saturating_from(value: usize) -> usize

Converts a value to its own type. This conversion is always valid and always leaves the value unchanged.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Implementors§