cairo_lang_sierra::extensions::modules::int

Trait IntTraits

Source
pub trait IntTraits: Default {
    type IntType: TryFrom<BigInt> + Into<BigInt> + Copy;

    const IS_SMALL: bool;
    const GENERIC_TYPE_ID: GenericTypeId;
    const CONST: &'static str;
    const EQUAL: &'static str;
    const TO_FELT252: &'static str;
    const TRY_FROM_FELT252: &'static str;
}
Expand description

Trait for implementing integers.

Required Associated Constants§

Source

const IS_SMALL: bool

Is the type smaller than 128 bits. Relevant since some implementations are different due to range check being 128 bits based.

Source

const GENERIC_TYPE_ID: GenericTypeId

The generic type id for this type.

Source

const CONST: &'static str

The generic libfunc id for getting a const of this type.

Source

const EQUAL: &'static str

The generic libfunc id for comparing equality.

Source

const TO_FELT252: &'static str

The generic libfunc id for conversion to felt252.

Source

const TRY_FROM_FELT252: &'static str

The generic libfunc id for conversion from felt252.

Required Associated Types§

Source

type IntType: TryFrom<BigInt> + Into<BigInt> + Copy

The rust matching type to this type.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl IntTraits for Sint128Traits

Source§

const GENERIC_TYPE_ID: GenericTypeId = _

Source§

const IS_SMALL: bool = false

Source§

const CONST: &'static str = "i128_const"

Source§

const EQUAL: &'static str = "i128_eq"

Source§

const TO_FELT252: &'static str = "i128_to_felt252"

Source§

const TRY_FROM_FELT252: &'static str = "i128_try_from_felt252"

Source§

type IntType = i128

Source§

impl IntTraits for Sint8Traits

Source§

const GENERIC_TYPE_ID: GenericTypeId = _

Source§

const IS_SMALL: bool = true

Source§

const CONST: &'static str = "i8_const"

Source§

const EQUAL: &'static str = "i8_eq"

Source§

const TO_FELT252: &'static str = "i8_to_felt252"

Source§

const TRY_FROM_FELT252: &'static str = "i8_try_from_felt252"

Source§

type IntType = i8

Source§

impl IntTraits for Sint16Traits

Source§

const GENERIC_TYPE_ID: GenericTypeId = _

Source§

const IS_SMALL: bool = true

Source§

const CONST: &'static str = "i16_const"

Source§

const EQUAL: &'static str = "i16_eq"

Source§

const TO_FELT252: &'static str = "i16_to_felt252"

Source§

const TRY_FROM_FELT252: &'static str = "i16_try_from_felt252"

Source§

type IntType = i16

Source§

impl IntTraits for Sint32Traits

Source§

const GENERIC_TYPE_ID: GenericTypeId = _

Source§

const IS_SMALL: bool = true

Source§

const CONST: &'static str = "i32_const"

Source§

const EQUAL: &'static str = "i32_eq"

Source§

const TO_FELT252: &'static str = "i32_to_felt252"

Source§

const TRY_FROM_FELT252: &'static str = "i32_try_from_felt252"

Source§

type IntType = i32

Source§

impl IntTraits for Sint64Traits

Source§

const GENERIC_TYPE_ID: GenericTypeId = _

Source§

const IS_SMALL: bool = true

Source§

const CONST: &'static str = "i64_const"

Source§

const EQUAL: &'static str = "i64_eq"

Source§

const TO_FELT252: &'static str = "i64_to_felt252"

Source§

const TRY_FROM_FELT252: &'static str = "i64_try_from_felt252"

Source§

type IntType = i64

Source§

impl IntTraits for Uint128Traits

Source§

const GENERIC_TYPE_ID: GenericTypeId = _

Source§

const IS_SMALL: bool = false

Source§

const CONST: &'static str = "u128_const"

Source§

const EQUAL: &'static str = "u128_eq"

Source§

const TO_FELT252: &'static str = "u128_to_felt252"

Source§

const TRY_FROM_FELT252: &'static str = "u128_try_from_felt252"

Source§

type IntType = u128

Source§

impl IntTraits for Uint8Traits

Source§

const GENERIC_TYPE_ID: GenericTypeId = _

Source§

const IS_SMALL: bool = true

Source§

const CONST: &'static str = "u8_const"

Source§

const EQUAL: &'static str = "u8_eq"

Source§

const TO_FELT252: &'static str = "u8_to_felt252"

Source§

const TRY_FROM_FELT252: &'static str = "u8_try_from_felt252"

Source§

type IntType = u8

Source§

impl IntTraits for Uint16Traits

Source§

const GENERIC_TYPE_ID: GenericTypeId = _

Source§

const IS_SMALL: bool = true

Source§

const CONST: &'static str = "u16_const"

Source§

const EQUAL: &'static str = "u16_eq"

Source§

const TO_FELT252: &'static str = "u16_to_felt252"

Source§

const TRY_FROM_FELT252: &'static str = "u16_try_from_felt252"

Source§

type IntType = u16

Source§

impl IntTraits for Uint32Traits

Source§

const GENERIC_TYPE_ID: GenericTypeId = _

Source§

const IS_SMALL: bool = true

Source§

const CONST: &'static str = "u32_const"

Source§

const EQUAL: &'static str = "u32_eq"

Source§

const TO_FELT252: &'static str = "u32_to_felt252"

Source§

const TRY_FROM_FELT252: &'static str = "u32_try_from_felt252"

Source§

type IntType = u32

Source§

impl IntTraits for Uint64Traits

Source§

const GENERIC_TYPE_ID: GenericTypeId = _

Source§

const IS_SMALL: bool = true

Source§

const CONST: &'static str = "u64_const"

Source§

const EQUAL: &'static str = "u64_eq"

Source§

const TO_FELT252: &'static str = "u64_to_felt252"

Source§

const TRY_FROM_FELT252: &'static str = "u64_try_from_felt252"

Source§

type IntType = u64