Skip to main content

IntegerExt

Trait IntegerExt 

Source
pub trait IntegerExt {
    // Required methods
    fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>, signed: bool) -> Ty<'tcx>;
    fn from_int_ty<C: HasDataLayout>(cx: &C, ity: IntTy) -> Integer;
    fn from_uint_ty<C: HasDataLayout>(cx: &C, ity: UintTy) -> Integer;
    fn discr_range_of_repr<'tcx>(
        tcx: TyCtxt<'tcx>,
        ty: Ty<'tcx>,
        repr: &ReprOptions,
        min_negative: i128,
        max_positive: u128,
    ) -> (Integer, bool);
}

Required Methods§

Source

fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>, signed: bool) -> Ty<'tcx>

Source

fn from_int_ty<C: HasDataLayout>(cx: &C, ity: IntTy) -> Integer

Source

fn from_uint_ty<C: HasDataLayout>(cx: &C, ity: UintTy) -> Integer

Source

fn discr_range_of_repr<'tcx>( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, repr: &ReprOptions, min_negative: i128, max_positive: u128, ) -> (Integer, bool)

Finds the appropriate Integer type and signedness for the given discriminant range and #[repr] attribute.

To represent the way the values were written in the rust source, min and max are in different types. It’s thus possible to pass in an unrepresentable range, and the method will panic in those cases.

This is the basis for computing the type of the tag of an enum (which can be smaller than the type of the discriminant, which is determined by ReprOptions::discr_type).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl IntegerExt for Integer

Source§

fn discr_range_of_repr<'tcx>( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, repr: &ReprOptions, min_negative: i128, max_positive: u128, ) -> (Integer, bool)

Finds the appropriate Integer type and signedness for the given discriminant range and #[repr] attribute.

To represent the way the values were written in the rust source, min and max are in different types. It’s thus possible to pass in an unrepresentable range, and the method will panic in those cases.

This is the basis for computing the type of the tag of an enum (which can be smaller than the type of the discriminant, which is determined by ReprOptions::discr_type).

Source§

fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>, signed: bool) -> Ty<'tcx>

Source§

fn from_int_ty<C: HasDataLayout>(cx: &C, ity: IntTy) -> Integer

Source§

fn from_uint_ty<C: HasDataLayout>(cx: &C, ity: UintTy) -> Integer

Implementors§