pub trait SignedLike: NumberLike<Signed = Self> {
    const ZERO: Self;

    // Required methods
    fn wrapping_add(self, other: Self) -> Self;
    fn wrapping_sub(self, other: Self) -> Self;
}
Expand description

Trait for data types that behave like signed integers.

This is used for delta encoding/decoding; i.e. the difference between consecutive numbers must be a SignedLike. For example,

  • The deltas between consecutive u64s are i64.
  • The deltas between consecutive i64s are i64.
  • The deltas between consecutive timestamps are i128.
  • The deltas between consecutive bools are bools (basically 1 bit signed integers under XOR).

This is important because deltas like +1 and -1 are numerically close to each other and easily compressible, which would not be the case with unsigned integers. Note: API stability of SignedLike is not guaranteed.

Required Associated Constants§

source

const ZERO: Self

Required Methods§

source

fn wrapping_add(self, other: Self) -> Self

source

fn wrapping_sub(self, other: Self) -> Self

Implementations on Foreign Types§

source§

impl SignedLike for bool

source§

const ZERO: Self = false

source§

fn wrapping_add(self, other: Self) -> Self

source§

fn wrapping_sub(self, other: Self) -> Self

source§

impl SignedLike for i64

source§

const ZERO: Self = 0i64

source§

fn wrapping_add(self, other: Self) -> Self

source§

fn wrapping_sub(self, other: Self) -> Self

source§

impl SignedLike for i16

source§

const ZERO: Self = 0i16

source§

fn wrapping_add(self, other: Self) -> Self

source§

fn wrapping_sub(self, other: Self) -> Self

source§

impl SignedLike for i32

source§

const ZERO: Self = 0i32

source§

fn wrapping_add(self, other: Self) -> Self

source§

fn wrapping_sub(self, other: Self) -> Self

Implementors§