Trait NumberBehavior

Source
pub trait NumberBehavior {
Show 60 methods // Required methods fn set_u8(&mut self, value: u8); fn set_u16(&mut self, value: u16); fn set_u32(&mut self, value: u32); fn set_u64(&mut self, value: u64); fn set_u128(&mut self, value: u128); fn set_i8(&mut self, value: i8); fn set_i16(&mut self, value: i16); fn set_i32(&mut self, value: i32); fn set_i64(&mut self, value: i64); fn set_i128(&mut self, value: i128); fn set_f32(&mut self, value: f32); fn set_f64(&mut self, value: f64); fn get_u8(&self) -> Option<u8>; fn get_u16(&self) -> Option<u16>; fn get_u32(&self) -> Option<u32>; fn get_u64(&self) -> Option<u64>; fn get_u128(&self) -> Option<u128>; fn get_i8(&self) -> Option<i8>; fn get_i16(&self) -> Option<i16>; fn get_i32(&self) -> Option<i32>; fn get_i64(&self) -> Option<i64>; fn get_i128(&self) -> Option<i128>; fn get_f32(&self) -> Option<f32>; fn get_f64(&self) -> Option<f64>; fn get_u8_unsafe(&self) -> u8; fn get_u16_unsafe(&self) -> u16; fn get_u32_unsafe(&self) -> u32; fn get_u64_unsafe(&self) -> u64; fn get_u128_unsafe(&self) -> u128; fn get_i8_unsafe(&self) -> i8; fn get_i16_unsafe(&self) -> i16; fn get_i32_unsafe(&self) -> i32; fn get_i64_unsafe(&self) -> i64; fn get_i128_unsafe(&self) -> i128; fn get_f32_unsafe(&self) -> f32; fn get_f64_unsafe(&self) -> f64; fn is_i8(&self) -> bool; fn is_i16(&self) -> bool; fn is_i32(&self) -> bool; fn is_i64(&self) -> bool; fn is_i128(&self) -> bool; fn is_u8(&self) -> bool; fn is_u16(&self) -> bool; fn is_u32(&self) -> bool; fn is_u64(&self) -> bool; fn is_u128(&self) -> bool; fn is_f32(&self) -> bool; fn is_f64(&self) -> bool; fn is_number(&self) -> bool; fn is_integer(&self) -> bool; fn is_float(&self) -> bool; fn is_signed(&self) -> bool; fn is_unsigned(&self) -> bool; fn is_zero(&self) -> bool; fn is_positive(&self) -> bool; fn is_negative(&self) -> bool; fn number_type(&self) -> NumberType; fn to_u64(&self) -> Option<u64>; fn to_i64(&self) -> Option<i64>; fn to_f64(&self) -> Option<f64>;
}

Required Methods§

Source

fn set_u8(&mut self, value: u8)

Sets the value of the Number struct to the given u8 value.

§Arguments
  • value - A u8 value to set in the Number struct.
§Examples
let mut num = Number::default();
num.set_u8(42);
Source

fn set_u16(&mut self, value: u16)

Source

fn set_u32(&mut self, value: u32)

Source

fn set_u64(&mut self, value: u64)

Source

fn set_u128(&mut self, value: u128)

Source

fn set_i8(&mut self, value: i8)

Source

fn set_i16(&mut self, value: i16)

Source

fn set_i32(&mut self, value: i32)

Source

fn set_i64(&mut self, value: i64)

Source

fn set_i128(&mut self, value: i128)

Source

fn set_f32(&mut self, value: f32)

Source

fn set_f64(&mut self, value: f64)

Source

fn get_u8(&self) -> Option<u8>

Returns the u8 value stored in the Number struct, if any.

§Returns

An Option<u8> containing the stored u8 value if it exists, or None otherwise.

§Examples
let mut num = Number::default();
num.set_u8(42);
assert_eq!(num.get_u8(), Some(42));
Source

fn get_u16(&self) -> Option<u16>

Source

fn get_u32(&self) -> Option<u32>

Source

fn get_u64(&self) -> Option<u64>

Source

fn get_u128(&self) -> Option<u128>

Source

fn get_i8(&self) -> Option<i8>

Source

fn get_i16(&self) -> Option<i16>

Source

fn get_i32(&self) -> Option<i32>

Source

fn get_i64(&self) -> Option<i64>

Source

fn get_i128(&self) -> Option<i128>

Source

fn get_f32(&self) -> Option<f32>

Source

fn get_f64(&self) -> Option<f64>

Source

fn get_u8_unsafe(&self) -> u8

Returns the u8 value stored in the Number struct, without checking if it exists.

§Safety

This function is unsafe because it can return an incorrect value if a u8 value is not stored in the Number struct.

§Examples
let mut num = Number::default();
num.set_u8(42);
unsafe { assert_eq!(num.get_u8_unsafe(), 42) };
Source

fn get_u16_unsafe(&self) -> u16

Source

fn get_u32_unsafe(&self) -> u32

Source

fn get_u64_unsafe(&self) -> u64

Source

fn get_u128_unsafe(&self) -> u128

Source

fn get_i8_unsafe(&self) -> i8

Source

fn get_i16_unsafe(&self) -> i16

Source

fn get_i32_unsafe(&self) -> i32

Source

fn get_i64_unsafe(&self) -> i64

Source

fn get_i128_unsafe(&self) -> i128

Source

fn get_f32_unsafe(&self) -> f32

Source

fn get_f64_unsafe(&self) -> f64

Source

fn is_i8(&self) -> bool

Checks if the stored number is of type i8.

§Returns

true if the stored number is of type i8, false otherwise.

§Examples
let mut num = Number::default();
num.set_i8(-42);
assert_eq!(num.is_i8(), true);
Source

fn is_i16(&self) -> bool

Source

fn is_i32(&self) -> bool

Source

fn is_i64(&self) -> bool

Source

fn is_i128(&self) -> bool

Source

fn is_u8(&self) -> bool

Source

fn is_u16(&self) -> bool

Source

fn is_u32(&self) -> bool

Source

fn is_u64(&self) -> bool

Source

fn is_u128(&self) -> bool

Source

fn is_f32(&self) -> bool

Source

fn is_f64(&self) -> bool

Source

fn is_number(&self) -> bool

Checks if the Number struct contains any value.

§Returns

true if the Number struct contains a value, false otherwise.

§Examples
let num = Number::default();
assert_eq!(num.is_number(), false);
Source

fn is_integer(&self) -> bool

Source

fn is_float(&self) -> bool

Source

fn is_signed(&self) -> bool

Source

fn is_unsigned(&self) -> bool

Source

fn is_zero(&self) -> bool

Source

fn is_positive(&self) -> bool

Source

fn is_negative(&self) -> bool

Source

fn number_type(&self) -> NumberType

fn is_integer(&self) -> bool { /* … */ } Determines the type of number stored in the Number struct.

§Returns

A NumberType variant representing the type of the stored number.

§Examples
let mut num = Number::default();
num.set_u32(42);
assert_eq!(num.number_type(), NumberType::U32);
Source

fn to_u64(&self) -> Option<u64>

Converts the Number struct to numeric types.

§Returns

An Option containing the converted numeric value if it exists, or None otherwise.

§Examples
let mut num = Number::default();
num.set_u32(42);
assert_eq!(num.to_i64(), Some(42));
Source

fn to_i64(&self) -> Option<i64>

Source

fn to_f64(&self) -> Option<f64>

Implementors§