Skip to main content

ToSigned

Trait ToSigned 

Source
pub trait ToSigned {
    type Type: Number + Signed;

    // Required method
    fn to_signed(&self) -> Self::Type;
}
Expand description

Converts a numeric type to its signed counterpart.

Maps each unsigned type to the corresponding signed type (e.g. u32i32). Signed types map to themselves.

§Examples

use platform_num::ToSigned;

let unsigned_val: u32 = 42;
let signed_val: i32 = unsigned_val.to_signed();
assert_eq!(signed_val, 42i32);

Required Associated Types§

Source

type Type: Number + Signed

The signed type that corresponds to Self.

Required Methods§

Source

fn to_signed(&self) -> Self::Type

Converts self to the corresponding signed type via as cast.

Implementations on Foreign Types§

Source§

impl ToSigned for i8

Source§

type Type = i8

Source§

fn to_signed(&self) -> Self::Type

Source§

impl ToSigned for i16

Source§

type Type = i16

Source§

fn to_signed(&self) -> Self::Type

Source§

impl ToSigned for i32

Source§

type Type = i32

Source§

fn to_signed(&self) -> Self::Type

Source§

impl ToSigned for i64

Source§

type Type = i64

Source§

fn to_signed(&self) -> Self::Type

Source§

impl ToSigned for i128

Source§

type Type = i128

Source§

fn to_signed(&self) -> Self::Type

Source§

impl ToSigned for isize

Source§

type Type = isize

Source§

fn to_signed(&self) -> Self::Type

Source§

impl ToSigned for u8

Source§

type Type = i8

Source§

fn to_signed(&self) -> Self::Type

Source§

impl ToSigned for u16

Source§

type Type = i16

Source§

fn to_signed(&self) -> Self::Type

Source§

impl ToSigned for u32

Source§

type Type = i32

Source§

fn to_signed(&self) -> Self::Type

Source§

impl ToSigned for u64

Source§

type Type = i64

Source§

fn to_signed(&self) -> Self::Type

Source§

impl ToSigned for u128

Source§

type Type = i128

Source§

fn to_signed(&self) -> Self::Type

Source§

impl ToSigned for usize

Source§

type Type = isize

Source§

fn to_signed(&self) -> Self::Type

Implementors§