Trait zigzag::ZigZagEncode[][src]

pub trait ZigZagEncode<U> {
    fn zigzag_encode(self) -> U;
}

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

fn zigzag_encode(self) -> U[src]

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);
Loading content...

Implementations on Foreign Types

impl ZigZagEncode<u8> for i8[src]

impl ZigZagEncode<u16> for i16[src]

impl ZigZagEncode<u32> for i32[src]

impl ZigZagEncode<u64> for i64[src]

impl ZigZagEncode<u128> for i128[src]

impl ZigZagEncode<usize> for isize[src]

Loading content...

Implementors

Loading content...