Movatterモバイル変換


[0]ホーム

URL:


Docs.rs

TraitToPrimitive

Source
pub trait ToPrimitive {
Show 14 methods // Required methods fnto_i64(&self) ->Option<i64>; fnto_u64(&self) ->Option<u64>; // Provided methods fnto_isize(&self) ->Option<isize> { ... } fnto_i8(&self) ->Option<i8> { ... } fnto_i16(&self) ->Option<i16> { ... } fnto_i32(&self) ->Option<i32> { ... } fnto_i128(&self) ->Option<i128> { ... } fnto_usize(&self) ->Option<usize> { ... } fnto_u8(&self) ->Option<u8> { ... } fnto_u16(&self) ->Option<u16> { ... } fnto_u32(&self) ->Option<u32> { ... } fnto_u128(&self) ->Option<u128> { ... } fnto_f32(&self) ->Option<f32> { ... } fnto_f64(&self) ->Option<f64> { ... }
}
Expand description

A generic trait for converting a value to a number.

A value can be represented by the target type when it lies withinthe range of scalars supported by the target type.For example, a negative integer cannot be represented by an unsignedinteger type, and ani64 with a very high magnitude might not beconvertible to ani32.On the other hand, conversions with possible precision loss or truncationare admitted, like anf32 with a decimal part to an integer type, oreven a largef64 saturating tof32 infinity.

Required Methods§

Source

fnto_i64(&self) ->Option<i64>

Converts the value ofself to ani64. If the value cannot berepresented by ani64, thenNone is returned.

Source

fnto_u64(&self) ->Option<u64>

Converts the value ofself to au64. If the value cannot berepresented by au64, thenNone is returned.

Provided Methods§

Source

fnto_isize(&self) ->Option<isize>

Converts the value ofself to anisize. If the value cannot berepresented by anisize, thenNone is returned.

Source

fnto_i8(&self) ->Option<i8>

Converts the value ofself to ani8. If the value cannot berepresented by ani8, thenNone is returned.

Source

fnto_i16(&self) ->Option<i16>

Converts the value ofself to ani16. If the value cannot berepresented by ani16, thenNone is returned.

Source

fnto_i32(&self) ->Option<i32>

Converts the value ofself to ani32. If the value cannot berepresented by ani32, thenNone is returned.

Source

fnto_i128(&self) ->Option<i128>

Converts the value ofself to ani128. If the value cannot berepresented by ani128 (i64 under the default implementation), thenNone is returned.

The default implementation converts throughto_i64(). Types implementingthis trait should override this method if they can represent a greater range.

Source

fnto_usize(&self) ->Option<usize>

Converts the value ofself to ausize. If the value cannot berepresented by ausize, thenNone is returned.

Source

fnto_u8(&self) ->Option<u8>

Converts the value ofself to au8. If the value cannot berepresented by au8, thenNone is returned.

Source

fnto_u16(&self) ->Option<u16>

Converts the value ofself to au16. If the value cannot berepresented by au16, thenNone is returned.

Source

fnto_u32(&self) ->Option<u32>

Converts the value ofself to au32. If the value cannot berepresented by au32, thenNone is returned.

Source

fnto_u128(&self) ->Option<u128>

Converts the value ofself to au128. If the value cannot berepresented by au128 (u64 under the default implementation), thenNone is returned.

The default implementation converts throughto_u64(). Types implementingthis trait should override this method if they can represent a greater range.

Source

fnto_f32(&self) ->Option<f32>

Converts the value ofself to anf32. Overflows may map to positiveor negative inifinity, otherwiseNone is returned if the value cannotbe represented by anf32.

Source

fnto_f64(&self) ->Option<f64>

Converts the value ofself to anf64. Overflows may map to positiveor negative inifinity, otherwiseNone is returned if the value cannotbe represented by anf64.

The default implementation tries to convert throughto_i64(), andfailing that throughto_u64(). Types implementing this trait shouldoverride this method if they can represent a greater range.

Implementations on Foreign Types§

Source§

implToPrimitive forf32

Source§

implToPrimitive forf64

Source§

implToPrimitive fori8

Source§

implToPrimitive fori16

Source§

implToPrimitive fori32

Source§

implToPrimitive fori64

Source§

implToPrimitive fori128

Source§

implToPrimitive forisize

Source§

implToPrimitive foru8

Source§

implToPrimitive foru16

Source§

implToPrimitive foru32

Source§

implToPrimitive foru64

Source§

implToPrimitive foru128

Source§

implToPrimitive forusize

Source§

impl<T:ToPrimitive>ToPrimitive forWrapping<T>

Implementors§


[8]ページ先頭

©2009-2025 Movatter.jp