Trait aoc_nums::Int

source ·
pub trait Int: Clone + Copy + Debug + Default + Display + Eq + FromStr + Hash + Ord + IntConv + IntOps {
    type Signed: IntSigned;
    type Unsigned: IntUnsigned;
Show 13 associated constants and 15 methods const BITS: u32; const ZERO: Self; const ONE: Self; const TWO: Self; const THREE: Self; const FOUR: Self; const FIVE: Self; const SIX: Self; const SEVEN: Self; const EIGHT: Self; const NINE: Self; const MIN: Self; const MAX: Self; // Required methods fn unsigned_abs(self) -> Self::Unsigned; fn signum(self) -> Self::Signed; fn signed_diff(self, other: Self) -> NumResult<Self::Signed>; fn unsigned_diff(self, other: Self) -> NumResult<Self::Unsigned>; fn add_signed(self, other: Self::Signed) -> NumResult<Self>; fn sub_signed(self, other: Self::Signed) -> NumResult<Self>; fn gen_count_ones(self) -> u32; // Provided methods fn check_bit(self, bit: u32) -> bool { ... } fn bit_set_assign(&mut self, bit: u32) { ... } fn bit_clear_assign(&mut self, bit: u32) { ... } fn bound_start_assign(&mut self, other: Self) { ... } fn bound_end_assign(&mut self, other: Self) { ... } fn bounds_assign(&mut self, bounds: impl RangeBounds<Self>) { ... } fn lcm(num_0: Self, num_1: Self) -> Self { ... } fn gcd(num_0: Self, num_1: Self) -> Self { ... }
}

Required Associated Types§

Required Associated Constants§

source

const BITS: u32

source

const ZERO: Self

source

const ONE: Self

source

const TWO: Self

source

const THREE: Self

source

const FOUR: Self

source

const FIVE: Self

source

const SIX: Self

source

const SEVEN: Self

source

const EIGHT: Self

source

const NINE: Self

source

const MIN: Self

source

const MAX: Self

Required Methods§

source

fn unsigned_abs(self) -> Self::Unsigned

source

fn signum(self) -> Self::Signed

source

fn signed_diff(self, other: Self) -> NumResult<Self::Signed>

Signed difference between two numbers

Errors

Returns Err (Overflow) if the result can’t be represented, ie if the difference is too high

source

fn unsigned_diff(self, other: Self) -> NumResult<Self::Unsigned>

Unsigned difference between two numbers

Errors

Returns Err (Overflow) if the result can’t be represented, ie if the second number is greater than the first

source

fn add_signed(self, other: Self::Signed) -> NumResult<Self>

Add a signed number

Errors

Returns Err (Overflow) if the result can’t be represented

source

fn sub_signed(self, other: Self::Signed) -> NumResult<Self>

Subtract a signed number

Errors

Returns Err (Overflow) if the result can’t be represented

source

fn gen_count_ones(self) -> u32

Generic wrapper for primitive count_ones function.

Provided Methods§

source

fn check_bit(self, bit: u32) -> bool

source

fn bit_set_assign(&mut self, bit: u32)

source

fn bit_clear_assign(&mut self, bit: u32)

source

fn bound_start_assign(&mut self, other: Self)

source

fn bound_end_assign(&mut self, other: Self)

source

fn bounds_assign(&mut self, bounds: impl RangeBounds<Self>)

source

fn lcm(num_0: Self, num_1: Self) -> Self

source

fn gcd(num_0: Self, num_1: Self) -> Self

Implementations on Foreign Types§

source§

impl Int for i8

§

type Signed = i8

§

type Unsigned = u8

source§

const BITS: u32 = 8u32

source§

const ZERO: i8 = 0i8

source§

const ONE: i8 = 1i8

source§

const TWO: i8 = 2i8

source§

const THREE: i8 = 3i8

source§

const FOUR: i8 = 4i8

source§

const FIVE: i8 = 5i8

source§

const SIX: i8 = 6i8

source§

const SEVEN: i8 = 7i8

source§

const EIGHT: i8 = 8i8

source§

const NINE: i8 = 9i8

source§

const MIN: i8 = -128i8

source§

const MAX: i8 = 127i8

source§

fn unsigned_abs(self) -> u8

source§

fn signum(self) -> i8

source§

fn signed_diff(self, other: Self) -> NumResult<i8>

source§

fn unsigned_diff(self, other: Self) -> NumResult<u8>

source§

fn add_signed(self, other: i8) -> NumResult<i8>

source§

fn sub_signed(self, other: i8) -> NumResult<i8>

source§

fn gen_count_ones(self) -> u32

source§

impl Int for i128

§

type Signed = i128

§

type Unsigned = u128

source§

const BITS: u32 = 128u32

source§

const ZERO: i128 = 0i128

source§

const ONE: i128 = 1i128

source§

const TWO: i128 = 2i128

source§

const THREE: i128 = 3i128

source§

const FOUR: i128 = 4i128

source§

const FIVE: i128 = 5i128

source§

const SIX: i128 = 6i128

source§

const SEVEN: i128 = 7i128

source§

const EIGHT: i128 = 8i128

source§

const NINE: i128 = 9i128

source§

const MIN: i128 = -170_141_183_460_469_231_731_687_303_715_884_105_728i128

source§

const MAX: i128 = 170_141_183_460_469_231_731_687_303_715_884_105_727i128

source§

fn unsigned_abs(self) -> u128

source§

fn signum(self) -> i128

source§

fn signed_diff(self, other: Self) -> NumResult<i128>

source§

fn unsigned_diff(self, other: Self) -> NumResult<u128>

source§

fn add_signed(self, other: i128) -> NumResult<i128>

source§

fn sub_signed(self, other: i128) -> NumResult<i128>

source§

fn gen_count_ones(self) -> u32

source§

impl Int for u32

§

type Signed = i32

§

type Unsigned = u32

source§

const BITS: u32 = 32u32

source§

const ZERO: u32 = 0u32

source§

const ONE: u32 = 1u32

source§

const TWO: u32 = 2u32

source§

const THREE: u32 = 3u32

source§

const FOUR: u32 = 4u32

source§

const FIVE: u32 = 5u32

source§

const SIX: u32 = 6u32

source§

const SEVEN: u32 = 7u32

source§

const EIGHT: u32 = 8u32

source§

const NINE: u32 = 9u32

source§

const MIN: u32 = 0u32

source§

const MAX: u32 = 4_294_967_295u32

source§

fn unsigned_abs(self) -> u32

source§

fn signum(self) -> i32

source§

fn signed_diff(self, other: Self) -> NumResult<i32>

source§

fn unsigned_diff(self, other: Self) -> NumResult<u32>

source§

fn add_signed(self, other: i32) -> NumResult<u32>

source§

fn sub_signed(self, other: i32) -> NumResult<u32>

source§

fn gen_count_ones(self) -> u32

source§

impl Int for u128

§

type Signed = i128

§

type Unsigned = u128

source§

const BITS: u32 = 128u32

source§

const ZERO: u128 = 0u128

source§

const ONE: u128 = 1u128

source§

const TWO: u128 = 2u128

source§

const THREE: u128 = 3u128

source§

const FOUR: u128 = 4u128

source§

const FIVE: u128 = 5u128

source§

const SIX: u128 = 6u128

source§

const SEVEN: u128 = 7u128

source§

const EIGHT: u128 = 8u128

source§

const NINE: u128 = 9u128

source§

const MIN: u128 = 0u128

source§

const MAX: u128 = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

source§

fn unsigned_abs(self) -> u128

source§

fn signum(self) -> i128

source§

fn signed_diff(self, other: Self) -> NumResult<i128>

source§

fn unsigned_diff(self, other: Self) -> NumResult<u128>

source§

fn add_signed(self, other: i128) -> NumResult<u128>

source§

fn sub_signed(self, other: i128) -> NumResult<u128>

source§

fn gen_count_ones(self) -> u32

source§

impl Int for i64

§

type Signed = i64

§

type Unsigned = u64

source§

const BITS: u32 = 64u32

source§

const ZERO: i64 = 0i64

source§

const ONE: i64 = 1i64

source§

const TWO: i64 = 2i64

source§

const THREE: i64 = 3i64

source§

const FOUR: i64 = 4i64

source§

const FIVE: i64 = 5i64

source§

const SIX: i64 = 6i64

source§

const SEVEN: i64 = 7i64

source§

const EIGHT: i64 = 8i64

source§

const NINE: i64 = 9i64

source§

const MIN: i64 = -9_223_372_036_854_775_808i64

source§

const MAX: i64 = 9_223_372_036_854_775_807i64

source§

fn unsigned_abs(self) -> u64

source§

fn signum(self) -> i64

source§

fn signed_diff(self, other: Self) -> NumResult<i64>

source§

fn unsigned_diff(self, other: Self) -> NumResult<u64>

source§

fn add_signed(self, other: i64) -> NumResult<i64>

source§

fn sub_signed(self, other: i64) -> NumResult<i64>

source§

fn gen_count_ones(self) -> u32

source§

impl Int for isize

§

type Signed = isize

§

type Unsigned = usize

source§

const BITS: u32 = 64u32

source§

const ZERO: isize = 0isize

source§

const ONE: isize = 1isize

source§

const TWO: isize = 2isize

source§

const THREE: isize = 3isize

source§

const FOUR: isize = 4isize

source§

const FIVE: isize = 5isize

source§

const SIX: isize = 6isize

source§

const SEVEN: isize = 7isize

source§

const EIGHT: isize = 8isize

source§

const NINE: isize = 9isize

source§

const MIN: isize = -9_223_372_036_854_775_808isize

source§

const MAX: isize = 9_223_372_036_854_775_807isize

source§

fn unsigned_abs(self) -> usize

source§

fn signum(self) -> isize

source§

fn signed_diff(self, other: Self) -> NumResult<isize>

source§

fn unsigned_diff(self, other: Self) -> NumResult<usize>

source§

fn add_signed(self, other: isize) -> NumResult<isize>

source§

fn sub_signed(self, other: isize) -> NumResult<isize>

source§

fn gen_count_ones(self) -> u32

source§

impl Int for i32

§

type Signed = i32

§

type Unsigned = u32

source§

const BITS: u32 = 32u32

source§

const ZERO: i32 = 0i32

source§

const ONE: i32 = 1i32

source§

const TWO: i32 = 2i32

source§

const THREE: i32 = 3i32

source§

const FOUR: i32 = 4i32

source§

const FIVE: i32 = 5i32

source§

const SIX: i32 = 6i32

source§

const SEVEN: i32 = 7i32

source§

const EIGHT: i32 = 8i32

source§

const NINE: i32 = 9i32

source§

const MIN: i32 = -2_147_483_648i32

source§

const MAX: i32 = 2_147_483_647i32

source§

fn unsigned_abs(self) -> u32

source§

fn signum(self) -> i32

source§

fn signed_diff(self, other: Self) -> NumResult<i32>

source§

fn unsigned_diff(self, other: Self) -> NumResult<u32>

source§

fn add_signed(self, other: i32) -> NumResult<i32>

source§

fn sub_signed(self, other: i32) -> NumResult<i32>

source§

fn gen_count_ones(self) -> u32

source§

impl Int for u16

§

type Signed = i16

§

type Unsigned = u16

source§

const BITS: u32 = 16u32

source§

const ZERO: u16 = 0u16

source§

const ONE: u16 = 1u16

source§

const TWO: u16 = 2u16

source§

const THREE: u16 = 3u16

source§

const FOUR: u16 = 4u16

source§

const FIVE: u16 = 5u16

source§

const SIX: u16 = 6u16

source§

const SEVEN: u16 = 7u16

source§

const EIGHT: u16 = 8u16

source§

const NINE: u16 = 9u16

source§

const MIN: u16 = 0u16

source§

const MAX: u16 = 65_535u16

source§

fn unsigned_abs(self) -> u16

source§

fn signum(self) -> i16

source§

fn signed_diff(self, other: Self) -> NumResult<i16>

source§

fn unsigned_diff(self, other: Self) -> NumResult<u16>

source§

fn add_signed(self, other: i16) -> NumResult<u16>

source§

fn sub_signed(self, other: i16) -> NumResult<u16>

source§

fn gen_count_ones(self) -> u32

source§

impl Int for u8

§

type Signed = i8

§

type Unsigned = u8

source§

const BITS: u32 = 8u32

source§

const ZERO: u8 = 0u8

source§

const ONE: u8 = 1u8

source§

const TWO: u8 = 2u8

source§

const THREE: u8 = 3u8

source§

const FOUR: u8 = 4u8

source§

const FIVE: u8 = 5u8

source§

const SIX: u8 = 6u8

source§

const SEVEN: u8 = 7u8

source§

const EIGHT: u8 = 8u8

source§

const NINE: u8 = 9u8

source§

const MIN: u8 = 0u8

source§

const MAX: u8 = 255u8

source§

fn unsigned_abs(self) -> u8

source§

fn signum(self) -> i8

source§

fn signed_diff(self, other: Self) -> NumResult<i8>

source§

fn unsigned_diff(self, other: Self) -> NumResult<u8>

source§

fn add_signed(self, other: i8) -> NumResult<u8>

source§

fn sub_signed(self, other: i8) -> NumResult<u8>

source§

fn gen_count_ones(self) -> u32

source§

impl Int for i16

§

type Signed = i16

§

type Unsigned = u16

source§

const BITS: u32 = 16u32

source§

const ZERO: i16 = 0i16

source§

const ONE: i16 = 1i16

source§

const TWO: i16 = 2i16

source§

const THREE: i16 = 3i16

source§

const FOUR: i16 = 4i16

source§

const FIVE: i16 = 5i16

source§

const SIX: i16 = 6i16

source§

const SEVEN: i16 = 7i16

source§

const EIGHT: i16 = 8i16

source§

const NINE: i16 = 9i16

source§

const MIN: i16 = -32_768i16

source§

const MAX: i16 = 32_767i16

source§

fn unsigned_abs(self) -> u16

source§

fn signum(self) -> i16

source§

fn signed_diff(self, other: Self) -> NumResult<i16>

source§

fn unsigned_diff(self, other: Self) -> NumResult<u16>

source§

fn add_signed(self, other: i16) -> NumResult<i16>

source§

fn sub_signed(self, other: i16) -> NumResult<i16>

source§

fn gen_count_ones(self) -> u32

source§

impl Int for usize

§

type Signed = isize

§

type Unsigned = usize

source§

const BITS: u32 = 64u32

source§

const ZERO: usize = 0usize

source§

const ONE: usize = 1usize

source§

const TWO: usize = 2usize

source§

const THREE: usize = 3usize

source§

const FOUR: usize = 4usize

source§

const FIVE: usize = 5usize

source§

const SIX: usize = 6usize

source§

const SEVEN: usize = 7usize

source§

const EIGHT: usize = 8usize

source§

const NINE: usize = 9usize

source§

const MIN: usize = 0usize

source§

const MAX: usize = 18_446_744_073_709_551_615usize

source§

fn unsigned_abs(self) -> usize

source§

fn signum(self) -> isize

source§

fn signed_diff(self, other: Self) -> NumResult<isize>

source§

fn unsigned_diff(self, other: Self) -> NumResult<usize>

source§

fn add_signed(self, other: isize) -> NumResult<usize>

source§

fn sub_signed(self, other: isize) -> NumResult<usize>

source§

fn gen_count_ones(self) -> u32

source§

impl Int for u64

§

type Signed = i64

§

type Unsigned = u64

source§

const BITS: u32 = 64u32

source§

const ZERO: u64 = 0u64

source§

const ONE: u64 = 1u64

source§

const TWO: u64 = 2u64

source§

const THREE: u64 = 3u64

source§

const FOUR: u64 = 4u64

source§

const FIVE: u64 = 5u64

source§

const SIX: u64 = 6u64

source§

const SEVEN: u64 = 7u64

source§

const EIGHT: u64 = 8u64

source§

const NINE: u64 = 9u64

source§

const MIN: u64 = 0u64

source§

const MAX: u64 = 18_446_744_073_709_551_615u64

source§

fn unsigned_abs(self) -> u64

source§

fn signum(self) -> i64

source§

fn signed_diff(self, other: Self) -> NumResult<i64>

source§

fn unsigned_diff(self, other: Self) -> NumResult<u64>

source§

fn add_signed(self, other: i64) -> NumResult<u64>

source§

fn sub_signed(self, other: i64) -> NumResult<u64>

source§

fn gen_count_ones(self) -> u32

Implementors§