pub trait ZigZagEncode<U> {
// Required method
fn zigzag_encode(self) -> U;
}Expand description
A trait intended to extend signed integer types with the ability to get their unsigned representation as derived by zigzag encoding.
This trait does so by implementing the zigzag_encode method.
Required Methods§
Sourcefn zigzag_encode(self) -> U
fn zigzag_encode(self) -> U
Decodes self into its unsigned counterpart by using zigzag encoding.
For more information on zigzag encoding, see its section in the crate documentation.
§Examples
use zigzag::ZigZagEncode;
assert_eq!(0i8.zigzag_encode(), 0u8);
assert_eq!((-1i8).zigzag_encode(), 1u8);
assert_eq!(1i8.zigzag_encode(), 2u8);