pub struct Tryte3 {
pub trits: [Trit; 3],
}Expand description
A tryte: exactly 3 trits = 27 states
Range: -13 to +13 in balanced ternary
Layout: [trit0 (LST), trit1, trit2 (MST)] Value = trit0 + 3×trit1 + 9×trit2
Fields§
§trits: [Trit; 3]Three trits, index 0 is least significant
Implementations§
Source§impl Tryte3
impl Tryte3
Sourcepub const NUM_STATES: u8 = 27
pub const NUM_STATES: u8 = 27
Number of distinct states
Sourcepub const fn new(t0: Trit, t1: Trit, t2: Trit) -> Self
pub const fn new(t0: Trit, t1: Trit, t2: Trit) -> Self
Create from three trits [LST, middle, MST]
Sourcepub const fn add_with_carry(
self,
other: Tryte3,
carry_in: Trit,
) -> (Tryte3, Trit)
pub const fn add_with_carry( self, other: Tryte3, carry_in: Trit, ) -> (Tryte3, Trit)
Arithmetic addition with carry out
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tryte3
impl<'de> Deserialize<'de> for Tryte3
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Tryte3
impl Eq for Tryte3
impl StructuralPartialEq for Tryte3
Auto Trait Implementations§
impl Freeze for Tryte3
impl RefUnwindSafe for Tryte3
impl Send for Tryte3
impl Sync for Tryte3
impl Unpin for Tryte3
impl UnwindSafe for Tryte3
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more