Trait JoinHalves

Source
pub trait JoinHalves: HasHalf {
    // Required method
    fn join_halves(upper: Self::Half, lower: Self::Half) -> Self;
}
Expand description

Provides a function to join two pieces into a number. For example, two u32s may be joined to form a u64.

Required Methods§

Source

fn join_halves(upper: Self::Half, lower: Self::Half) -> Self

Joins two values into a single value; the upper, or most-significant, half comes first.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl JoinHalves for u16

Source§

fn join_halves(upper: Self::Half, lower: Self::Half) -> Self

Joins two unsigned integers to form an unsigned integer with twice the width.

Let $W$ be the width of Self (the output type).

$f(x, y) = 2^{W/2} x + y$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl JoinHalves for u32

Source§

fn join_halves(upper: Self::Half, lower: Self::Half) -> Self

Joins two unsigned integers to form an unsigned integer with twice the width.

Let $W$ be the width of Self (the output type).

$f(x, y) = 2^{W/2} x + y$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl JoinHalves for u64

Source§

fn join_halves(upper: Self::Half, lower: Self::Half) -> Self

Joins two unsigned integers to form an unsigned integer with twice the width.

Let $W$ be the width of Self (the output type).

$f(x, y) = 2^{W/2} x + y$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl JoinHalves for u128

Source§

fn join_halves(upper: Self::Half, lower: Self::Half) -> Self

Joins two unsigned integers to form an unsigned integer with twice the width.

Let $W$ be the width of Self (the output type).

$f(x, y) = 2^{W/2} x + y$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Implementors§