PowerOfTwo in typenum::marker_traits - Rust
Description: The marker trait for type-level numbers which are a power of two.
Keywords: rust, rustlang, rust-lang, PowerOfTwo

# Trait typenum::marker_traits::PowerOfTwo

source ·

    pub trait PowerOfTwo: Sealed { }

Expand description

The marker trait for type-level numbers which are a power of two.

## Examples

Here’s a working example:

    use typenum::{PowerOfTwo, P4, P8};

    fn only_p2<P: PowerOfTwo>() {}

    only_p2::<P4>();
    only_p2::<P8>();

Numbers which are not a power of two will fail to compile in this example:

ⓘ

    use typenum::{P9, P511, P1023, PowerOfTwo};

    fn only_p2<P: PowerOfTwo>() { }

    only_p2::<P9>();
    only_p2::<P511>();
    only_p2::<P1023>();

## Implementors§

source§

### impl PowerOfTwo for B1

source§

### impl PowerOfTwo for UInt<UTerm, B1>

source§

### impl<U: Unsigned + NonZero + PowerOfTwo> PowerOfTwo for PInt<U>

source§

### impl<U: Unsigned + PowerOfTwo> PowerOfTwo for UInt<U, B0>