pub struct IntegerInfo {
pub signed: bool,
pub width: u32,
}Expand description
What an integer type is once it no longer matters how it was spelled.
A width and a signedness, which between them are everything the value of an integer constant
depends on. int, an enumeration represented in int, and _BitInt(32) are three different
types with one IntegerInfo, and every question about what a constant of any of them holds
has the same answer for all three.
The width is the value’s and not the object’s. bool is one bit here and one byte in
layout, and _BitInt(37) is thirty seven bits here and eight bytes there.
Fields§
§signed: boolWhether the type can hold a negative value.
width: u32How many bits of a value the type keeps.
Implementations§
Source§impl IntegerInfo
impl IntegerInfo
Sourcepub const fn new(signed: bool, width: u32) -> IntegerInfo
pub const fn new(signed: bool, width: u32) -> IntegerInfo
An integer type of the given signedness and width.
Sourcepub const fn wrap(self, raw: i128) -> i128
pub const fn wrap(self, raw: i128) -> i128
The value raw becomes once it is stored in a type of this shape.
The low width bits of it, extended into the rest by the signedness. That is the form a
folded constant is held in, so 300 wrapped by a char is 44, -1 wrapped by an
unsigned int is 4294967295, and a value of a hundred and twenty eight bit type is
itself, because there is nothing wider left to extend it into.
Sourcepub const fn holds(self, raw: i128) -> bool
pub const fn holds(self, raw: i128) -> bool
Whether raw is a value a type of this shape can hold.
Every hundred and twenty eight bit pattern is a value of a hundred and twenty eight bit
type, of either signedness, which is why this is a question about the width rather than
a comparison against a pair of bounds: unsigned __int128 has a greatest value that no
i128 can be handed to ask about.
Trait Implementations§
Source§impl Clone for IntegerInfo
impl Clone for IntegerInfo
Source§fn clone(&self) -> IntegerInfo
fn clone(&self) -> IntegerInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more