Trait hacspec_lib::prelude::Integer
source · [−]pub trait Integer: Numeric {
const NUM_BITS: usize;
fn ZERO() -> Self;
fn ONE() -> Self;
fn TWO() -> Self;
fn from_literal(val: u128) -> Self;
fn from_hex_string(s: &String) -> Self;
fn get_bit(self, i: usize) -> Self;
fn set_bit(self, b: Self, i: usize) -> Self;
fn set(self, pos: usize, y: Self, yi: usize) -> Self;
fn rotate_left(self, n: usize) -> Self;
fn rotate_right(self, n: usize) -> Self;
}
Expand description
This trait extends the Numeric
trait and is implemented by all integer
types. It offers bit manipulation, instantiation from literal, and convenient
constants.
Required Associated Constants
Required Methods
fn from_literal(val: u128) -> Self
fn from_literal(val: u128) -> Self
Get an integer with value val
.
fn from_hex_string(s: &String) -> Self
fn from_hex_string(s: &String) -> Self
Read a hex string (starting with 0x) into an Integer
.
fn rotate_left(self, n: usize) -> Self
fn rotate_right(self, n: usize) -> Self
Implementations on Foreign Types
sourceimpl Integer for u8
impl Integer for u8
sourcefn ZERO() -> Self
fn ZERO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn ONE() -> Self
fn ONE() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn TWO() -> Self
fn TWO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_literal(val: u128) -> Self
fn from_literal(val: u128) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_hex_string(s: &String) -> Self
fn from_hex_string(s: &String) -> Self
This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec
sourcefn get_bit(self, i: usize) -> Self
fn get_bit(self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Get bit i
of this integer.
sourcefn set_bit(self, b: Self, i: usize) -> Self
fn set_bit(self, b: Self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit i
of this integer to b
and return the result.
Bit b
has to be 0
or 1
.
sourcefn set(self, pos: usize, y: Self, yi: usize) -> Self
fn set(self, pos: usize, y: Self, yi: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit pos
of this integer to bit yi
of integer y
.
sourcefn rotate_left(self, n: usize) -> Self
fn rotate_left(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn rotate_right(self, n: usize) -> Self
fn rotate_right(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
const NUM_BITS: usize = 8usize
sourceimpl Integer for u16
impl Integer for u16
sourcefn ZERO() -> Self
fn ZERO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn ONE() -> Self
fn ONE() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn TWO() -> Self
fn TWO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_literal(val: u128) -> Self
fn from_literal(val: u128) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_hex_string(s: &String) -> Self
fn from_hex_string(s: &String) -> Self
This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec
sourcefn get_bit(self, i: usize) -> Self
fn get_bit(self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Get bit i
of this integer.
sourcefn set_bit(self, b: Self, i: usize) -> Self
fn set_bit(self, b: Self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit i
of this integer to b
and return the result.
Bit b
has to be 0
or 1
.
sourcefn set(self, pos: usize, y: Self, yi: usize) -> Self
fn set(self, pos: usize, y: Self, yi: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit pos
of this integer to bit yi
of integer y
.
sourcefn rotate_left(self, n: usize) -> Self
fn rotate_left(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn rotate_right(self, n: usize) -> Self
fn rotate_right(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
const NUM_BITS: usize = 16usize
sourceimpl Integer for u32
impl Integer for u32
sourcefn ZERO() -> Self
fn ZERO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn ONE() -> Self
fn ONE() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn TWO() -> Self
fn TWO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_literal(val: u128) -> Self
fn from_literal(val: u128) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_hex_string(s: &String) -> Self
fn from_hex_string(s: &String) -> Self
This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec
sourcefn get_bit(self, i: usize) -> Self
fn get_bit(self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Get bit i
of this integer.
sourcefn set_bit(self, b: Self, i: usize) -> Self
fn set_bit(self, b: Self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit i
of this integer to b
and return the result.
Bit b
has to be 0
or 1
.
sourcefn set(self, pos: usize, y: Self, yi: usize) -> Self
fn set(self, pos: usize, y: Self, yi: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit pos
of this integer to bit yi
of integer y
.
sourcefn rotate_left(self, n: usize) -> Self
fn rotate_left(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn rotate_right(self, n: usize) -> Self
fn rotate_right(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
const NUM_BITS: usize = 32usize
sourceimpl Integer for u64
impl Integer for u64
sourcefn ZERO() -> Self
fn ZERO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn ONE() -> Self
fn ONE() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn TWO() -> Self
fn TWO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_literal(val: u128) -> Self
fn from_literal(val: u128) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_hex_string(s: &String) -> Self
fn from_hex_string(s: &String) -> Self
This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec
sourcefn get_bit(self, i: usize) -> Self
fn get_bit(self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Get bit i
of this integer.
sourcefn set_bit(self, b: Self, i: usize) -> Self
fn set_bit(self, b: Self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit i
of this integer to b
and return the result.
Bit b
has to be 0
or 1
.
sourcefn set(self, pos: usize, y: Self, yi: usize) -> Self
fn set(self, pos: usize, y: Self, yi: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit pos
of this integer to bit yi
of integer y
.
sourcefn rotate_left(self, n: usize) -> Self
fn rotate_left(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn rotate_right(self, n: usize) -> Self
fn rotate_right(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
const NUM_BITS: usize = 64usize
sourceimpl Integer for u128
impl Integer for u128
sourcefn ZERO() -> Self
fn ZERO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn ONE() -> Self
fn ONE() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn TWO() -> Self
fn TWO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_literal(val: u128) -> Self
fn from_literal(val: u128) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_hex_string(s: &String) -> Self
fn from_hex_string(s: &String) -> Self
This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec
sourcefn get_bit(self, i: usize) -> Self
fn get_bit(self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Get bit i
of this integer.
sourcefn set_bit(self, b: Self, i: usize) -> Self
fn set_bit(self, b: Self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit i
of this integer to b
and return the result.
Bit b
has to be 0
or 1
.
sourcefn set(self, pos: usize, y: Self, yi: usize) -> Self
fn set(self, pos: usize, y: Self, yi: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit pos
of this integer to bit yi
of integer y
.
sourcefn rotate_left(self, n: usize) -> Self
fn rotate_left(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn rotate_right(self, n: usize) -> Self
fn rotate_right(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
const NUM_BITS: usize = 128usize
sourceimpl Integer for i8
impl Integer for i8
sourcefn ZERO() -> Self
fn ZERO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn ONE() -> Self
fn ONE() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn TWO() -> Self
fn TWO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_literal(val: u128) -> Self
fn from_literal(val: u128) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_hex_string(s: &String) -> Self
fn from_hex_string(s: &String) -> Self
This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec
sourcefn get_bit(self, i: usize) -> Self
fn get_bit(self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Get bit i
of this integer.
sourcefn set_bit(self, b: Self, i: usize) -> Self
fn set_bit(self, b: Self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit i
of this integer to b
and return the result.
Bit b
has to be 0
or 1
.
sourcefn set(self, pos: usize, y: Self, yi: usize) -> Self
fn set(self, pos: usize, y: Self, yi: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit pos
of this integer to bit yi
of integer y
.
sourcefn rotate_left(self, n: usize) -> Self
fn rotate_left(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn rotate_right(self, n: usize) -> Self
fn rotate_right(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
const NUM_BITS: usize = 8usize
sourceimpl Integer for i16
impl Integer for i16
sourcefn ZERO() -> Self
fn ZERO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn ONE() -> Self
fn ONE() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn TWO() -> Self
fn TWO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_literal(val: u128) -> Self
fn from_literal(val: u128) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_hex_string(s: &String) -> Self
fn from_hex_string(s: &String) -> Self
This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec
sourcefn get_bit(self, i: usize) -> Self
fn get_bit(self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Get bit i
of this integer.
sourcefn set_bit(self, b: Self, i: usize) -> Self
fn set_bit(self, b: Self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit i
of this integer to b
and return the result.
Bit b
has to be 0
or 1
.
sourcefn set(self, pos: usize, y: Self, yi: usize) -> Self
fn set(self, pos: usize, y: Self, yi: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit pos
of this integer to bit yi
of integer y
.
sourcefn rotate_left(self, n: usize) -> Self
fn rotate_left(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn rotate_right(self, n: usize) -> Self
fn rotate_right(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
const NUM_BITS: usize = 16usize
sourceimpl Integer for i32
impl Integer for i32
sourcefn ZERO() -> Self
fn ZERO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn ONE() -> Self
fn ONE() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn TWO() -> Self
fn TWO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_literal(val: u128) -> Self
fn from_literal(val: u128) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_hex_string(s: &String) -> Self
fn from_hex_string(s: &String) -> Self
This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec
sourcefn get_bit(self, i: usize) -> Self
fn get_bit(self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Get bit i
of this integer.
sourcefn set_bit(self, b: Self, i: usize) -> Self
fn set_bit(self, b: Self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit i
of this integer to b
and return the result.
Bit b
has to be 0
or 1
.
sourcefn set(self, pos: usize, y: Self, yi: usize) -> Self
fn set(self, pos: usize, y: Self, yi: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit pos
of this integer to bit yi
of integer y
.
sourcefn rotate_left(self, n: usize) -> Self
fn rotate_left(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn rotate_right(self, n: usize) -> Self
fn rotate_right(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
const NUM_BITS: usize = 32usize
sourceimpl Integer for i64
impl Integer for i64
sourcefn ZERO() -> Self
fn ZERO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn ONE() -> Self
fn ONE() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn TWO() -> Self
fn TWO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_literal(val: u128) -> Self
fn from_literal(val: u128) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_hex_string(s: &String) -> Self
fn from_hex_string(s: &String) -> Self
This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec
sourcefn get_bit(self, i: usize) -> Self
fn get_bit(self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Get bit i
of this integer.
sourcefn set_bit(self, b: Self, i: usize) -> Self
fn set_bit(self, b: Self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit i
of this integer to b
and return the result.
Bit b
has to be 0
or 1
.
sourcefn set(self, pos: usize, y: Self, yi: usize) -> Self
fn set(self, pos: usize, y: Self, yi: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit pos
of this integer to bit yi
of integer y
.
sourcefn rotate_left(self, n: usize) -> Self
fn rotate_left(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn rotate_right(self, n: usize) -> Self
fn rotate_right(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
const NUM_BITS: usize = 64usize
sourceimpl Integer for i128
impl Integer for i128
sourcefn ZERO() -> Self
fn ZERO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn ONE() -> Self
fn ONE() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn TWO() -> Self
fn TWO() -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_literal(val: u128) -> Self
fn from_literal(val: u128) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn from_hex_string(s: &String) -> Self
fn from_hex_string(s: &String) -> Self
This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec
sourcefn get_bit(self, i: usize) -> Self
fn get_bit(self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Get bit i
of this integer.
sourcefn set_bit(self, b: Self, i: usize) -> Self
fn set_bit(self, b: Self, i: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit i
of this integer to b
and return the result.
Bit b
has to be 0
or 1
.
sourcefn set(self, pos: usize, y: Self, yi: usize) -> Self
fn set(self, pos: usize, y: Self, yi: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.
Set bit pos
of this integer to bit yi
of integer y
.
sourcefn rotate_left(self, n: usize) -> Self
fn rotate_left(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.
sourcefn rotate_right(self, n: usize) -> Self
fn rotate_right(self, n: usize) -> Self
This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and call functions whose signatures are in hacspec.