integer

Integer types and operations.This module provides the built-in integer types and their associated operations. # Integer TypesThe following integer types are available:Unsigned integers: u8, u16, u32, u64, u128, u256 * Signed integers: i8, i16, i32, i64, i128 # OperationsInteger types implement various traits that enable common operations:Basic arithmetic via Add, Sub, Mul, Div, Rem and DivRem * Bitwise operations via BitAnd, BitOr, BitXor, and BitNot * Comparison via PartialEq and PartialOrd * Safe arithmetic via CheckedAdd, CheckedSub, CheckedMul * Wrapping arithmetic via WrappingAdd, WrappingSub, WrappingMul * Overflow handling via OverflowingAdd, OverflowingSub, OverflowingMulAdd: crate::traits::Add Sub: crate::traits::Sub Mul: crate::traits::Mul Div: crate::traits::Div Rem: crate::traits::Rem DivRem: crate::traits::DivRem CheckedAdd: crate::num::traits::ops::checked::CheckedAdd CheckedSub: crate::num::traits::ops::checked::CheckedSub CheckedMul: crate::num::traits::ops::checked::CheckedMul WrappingAdd: crate::num::traits::ops::wrapping::WrappingAdd WrappingSub: crate::num::traits::ops::wrapping::WrappingSub WrappingMul: crate::num::traits::ops::wrapping::WrappingMul OverflowingAdd: crate::num::traits::ops::overflowing::OverflowingAdd OverflowingSub: crate::num::traits::ops::overflowing::OverflowingSub OverflowingMul: crate::num::traits::ops::overflowing::OverflowingMul # ExamplesBasic operators:

let a: u8 = 5;
let b: u8 = 10;
assert_eq!(a + b, 15);
assert_eq!(a * b, 50);
assert_eq!(a & b, 0);
assert!(a < b);

Checked operations:

use core::num::traits::{CheckedAdd, Bounded};

let max: u8 = Bounded::MAX;
assert!(max.checked_add(1_u8).is_none());

ConversionsIntegers can be converted between different types using:TryInto for potentially fallible conversions * Into for infallible conversions to wider types

Fully qualified path: core::integer

Free functions

Structs

Traits

Extern types

Extern functions