[][src]Trait bitvec::cursor::Cursor

pub trait Cursor {
    const TYPENAME: &'static str;

    fn at<T>(cursor: BitIdx) -> BitPos
    where
        T: BitStore
; }

A cursor over an element.

Usage

bitvec structures store and operate on semantic counts, not bit positions. The Cursor::at function takes a semantic cursor, BitIdx, and produces an electrical position, BitPos.

Associated Constants

const TYPENAME: &'static str

Name of the cursor type, for use in text display.

Loading content...

Required methods

fn at<T>(cursor: BitIdx) -> BitPos where
    T: BitStore

Translate a semantic bit index into an electrical bit position.

Parameters

  • cursor: The semantic bit value.

Returns

  • A concrete position. This value can be used for shifting and masking to extract a bit from an element. This must be in the domain 0 .. T::BITS.

Type Parameters

  • T: BitStore: The storage type for which the position will be calculated.

Invariants

The function must be total for the domain .. T::BITS. All values in this domain are valid indices that the library will pass to it, and which this function must satisfy.

The function must be bijective over the domain .. T::BITS. All input values in this domain must have one and only one correpsonding output, which must also be in this domain.

The function may support input in the domain T::BITS ... The library will not produce any values in this domain as input indices. The function must not produce output in the domain T::BITS ... It must choose between panicking, or producing an output in .. T::BITS. The reduction in domain from T::BITS .. to .. T::BITS removes the requirement for inputs in T::BITS .. to have unique outputs in .. T::BITS.

This function must be pure. Calls which have the same input must produce the same output. This invariant is only required to be upheld for the lifetime of all data structures which use an implementor. The behavior of the function may be modified after all existing dependent data structures are destroyed and before any new dependent data structures are created.

Non-Invariants

This function is not required to be stateless. It may refer to immutable global state, subject to the purity requirement on lifetimes.

Safety

This function requires that the output be in the domain .. T::BITS. Implementors must uphold this themselves. Outputs in the domain T::BITS .. will induce panics elsewhere in the library.

Loading content...

Implementors

impl Cursor for BigEndian[src]

fn at<T>(cursor: BitIdx) -> BitPos where
    T: BitStore
[src]

Maps a semantic count to a concrete position.

BigEndian order moves from MSbit first to LSbit last.

impl Cursor for LittleEndian[src]

fn at<T>(cursor: BitIdx) -> BitPos where
    T: BitStore
[src]

Maps a semantic count to a concrete position.

LittleEndian order moves from LSbit first to MSbit last.

Loading content...