pub trait FromOtherTypeSlice<T: Sized> {
    fn from_other_type_slice(slice: &[T]) -> Self;
}
Expand description

Converts a slice of one type of value to a single value of another type.

Required Methods§

Implementations on Foreign Types§

Converts a slice of one type of value to a single value of the same type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ x_0 & \text{otherwise}, \end{cases} $$ where $W$ is the width of the type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If there’s more than one element in the input slice, the value wraps and all elements past the first are ignored. This means that if the slice is empty, the output value is 0; otherwise, it’s the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of value to a single value of the same type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ x_0 & \text{otherwise}, \end{cases} $$ where $W$ is the width of the type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If there’s more than one element in the input slice, the value wraps and all elements past the first are ignored. This means that if the slice is empty, the output value is 0; otherwise, it’s the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of value to a single value of the same type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ x_0 & \text{otherwise}, \end{cases} $$ where $W$ is the width of the type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If there’s more than one element in the input slice, the value wraps and all elements past the first are ignored. This means that if the slice is empty, the output value is 0; otherwise, it’s the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of value to a single value of the same type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ x_0 & \text{otherwise}, \end{cases} $$ where $W$ is the width of the type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If there’s more than one element in the input slice, the value wraps and all elements past the first are ignored. This means that if the slice is empty, the output value is 0; otherwise, it’s the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of value to a single value of the same type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ x_0 & \text{otherwise}, \end{cases} $$ where $W$ is the width of the type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If there’s more than one element in the input slice, the value wraps and all elements past the first are ignored. This means that if the slice is empty, the output value is 0; otherwise, it’s the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of value to a single value of the same type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ x_0 & \text{otherwise}, \end{cases} $$ where $W$ is the width of the type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If there’s more than one element in the input slice, the value wraps and all elements past the first are ignored. This means that if the slice is empty, the output value is 0; otherwise, it’s the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a smaller unsigned type.

$$ f((x_k)_{k=0}^{n-1}) = \begin{cases} 0 & \text{if} \quad n = 0, \\ y & \text{otherwise}, \end{cases} $$ where $0 \leq y < 2^W$, $x = y + k2^W$ for some integer $k$, and $W$ is the width of the output type.

The slice is interpreted as the base-$2^W$ digits of the value, in ascending order, where $W$ is the width of the type. If the slice is empty, the output value is 0; otherwise, it consists of the least-significant bits of the first element of the slice.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of one type of unsigned integer to a single value of a larger unsigned type.

Let $V$ be the the width of the input type and $W$ the width of the output type.

$f((x_k)_{k=0}^{n-1}) = y$, where $y < 2^W$ and

$$ y = k2^W + \sum_{j=0}^{n-1}2^{jV}x_j $$

for some integer $k$.

If the input slice contains more values than necessary to build an output value, the trailing values are ignored. If the input slice contains too few values to build an output value, the most-significant bits of the output value are set to 0.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Converts a slice of u32s to a single usize.

Worst-case complexity

Constant time and additional memory.

See here.

Converts a slice of u64s to a single usize.

Worst-case complexity

Constant time and additional memory.

See here.

Converts a slice of usizes to a single u32.

Worst-case complexity

Constant time and additional memory.

See here.

Converts a slice of usizes to a single u64.

Worst-case complexity

Constant time and additional memory.

See here.

Implementors§