pub struct Bits { /* private fields */ }
Expand description

Bits representation.

Implementations§

Create a new representation of Bits.

Examples
extern crate xor_distance_exercise;
use xor_distance_exercise::bits::Bits;

Bits::new::<u64>;

Return bit size of the type being represent in bits.

Examples
extern crate xor_distance_exercise;

use xor_distance_exercise::bits::Bits;

assert_eq!(8, Bits::bit_size::<u8>());
assert_eq!(32, Bits::bit_size::<u32>());
assert_eq!(64, Bits::bit_size::<u64>());
assert_eq!(64, Bits::bit_size::<i64>());

Get bit value for the index.

Panics

Panics if index is out of range.

Set new bit value for the index.

Panics

Panics if index is out of range.

Set new bit value complying with constrains, already decided bit value can not be changed.

Returns Ok(()) in case constrains were not violated, Err(&str) otherwise.

Panics

Panics if index is out of range.

Is bit decided already?

Panics

Panics if index is out of range.

Form and return a number based on bits representation, pad/fill undecided bits by zeros.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.