ZigZagEncode

Trait ZigZagEncode 

Source
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§

Source

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);

Implementations on Foreign Types§

Source§

impl ZigZagEncode<u8> for i8

Source§

impl ZigZagEncode<u16> for i16

Source§

impl ZigZagEncode<u32> for i32

Source§

impl ZigZagEncode<u64> for i64

Source§

impl ZigZagEncode<u128> for i128

Source§

impl ZigZagEncode<usize> for isize

Implementors§