Struct bitvec::prelude::BitPtrRange[][src]

#[repr(C, align(8))]
pub struct BitPtrRange<M, O = Lsb0, T = usize> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
{ pub start: BitPtr<M, O, T>, pub end: BitPtr<M, O, T>, }

Equivalent to Range<BitPtr<M, O, T>>.

As with Range, this is a half-open set: the starting pointer is included in the set of live addresses, while the ending pointer is one-past-the-end of live addresses, and is not usable.

This structure exists because Range does not permit foreign implementations of its internal traits.

Original

Range<*bool>

API Differences

This cannot be constructed directly from the .. syntax, though a From implementation is provided.

Type Parameters

  • M: The write permissions of the pointers this range produces.
  • O: The bit-ordering within a storage element used to access bits.
  • T: The storage element type containing the referent bits.

Fields

start: BitPtr<M, O, T>

The lower bound of the range (inclusive).

end: BitPtr<M, O, T>

The higher bound of the range (exclusive).

Implementations

impl<M, O, T> BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

pub const EMPTY: Self[src]

The canonical empty range. All ranges with zero length are equally empty.

pub fn raw_parts(&self) -> (BitPtr<M, O, T>, BitPtr<M, O, T>)[src]

Destructures the range back into its start and end pointers.

pub fn into_range(self) -> Range<BitPtr<M, O, T>>[src]

Converts the structure into an actual Range. The Range will have limited functionality compared to self.

pub fn is_empty(&self) -> bool[src]

Tests if the range is empty (the distance between pointers is 0).

Original

Range::is_empty

Examples

use bitvec::prelude::*;
use bitvec::ptr::BitPtrRange;

let data = 0u8;
let ptr = BitPtr::<_, Lsb0, _>::from_ref(&data);
let mut range = unsafe { ptr.range(1) };

assert!(!range.is_empty());
range.next();
assert!(range.is_empty());

pub fn contains<M2, T2>(&self, pointer: &BitPtr<M2, O, T2>) -> bool where
    M2: Mutability,
    T2: BitStore
[src]

Returns true if the pointer is contained in the range.

Original

Range::contains

API Differences

The candidate pointer may differ in mutability permissions and exact storage type.

If T2::Mem is not T::Mem, then this always returns false. If T2 and T have the same memory type, but different alias permissions, then the comparison can continue.

Examples

use bitvec::prelude::*;
use bitvec::ptr::BitPtrRange;
use core::cell::Cell;

let data = 0u16;
let ptr = BitPtr::<_, Lsb0, _>::from_ref(&data);

let mut range = unsafe { ptr.range(16) };
// Reduce the range contents.
range.nth(2);
range.nth_back(2);

// The start pointer is now excluded, but the interior remains.
assert!(!range.contains(&ptr));
assert!(range.contains(&unsafe { ptr.add(8) }));

// Different base types are always excluded.
let casted = ptr.cast::<u8>();
assert!(!range.contains(&unsafe { casted.add(8) }));

// Casting to a different alias model with the same width is valid.
let casted = ptr.cast::<Cell<u16>>();
assert!(range.contains(&unsafe { casted.add(8) }));

Trait Implementations

impl<M, O, T> Clone for BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

impl<M, O, T> Debug for BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

impl<M, O, T> Default for BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

impl<M, O, T> DoubleEndedIterator for BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

impl<M, O, T> Eq for BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

impl<M, O, T> ExactSizeIterator for BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

impl<M, O, T> From<Range<BitPtr<M, O, T>>> for BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

impl<M, O, T> FusedIterator for BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

impl<M, O, T> Hash for BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

impl<M, O, T> Iterator for BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

type Item = BitPtr<M, O, T>

The type of the elements being iterated over.

impl<M1, M2, O, T1, T2> PartialEq<BitPtrRange<M2, O, T2>> for BitPtrRange<M1, O, T1> where
    M1: Mutability,
    M2: Mutability,
    O: BitOrder,
    T1: BitStore,
    T2: BitStore
[src]

impl<M, O, T> RangeBounds<BitPtr<M, O, T>> for BitPtrRange<M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore
[src]

Auto Trait Implementations

impl<M, O, T> RefUnwindSafe for BitPtrRange<M, O, T> where
    M: RefUnwindSafe,
    O: RefUnwindSafe,
    T: RefUnwindSafe,
    <T as BitStore>::Mem: RefUnwindSafe

impl<M, O = Lsb0, T = usize> !Send for BitPtrRange<M, O, T>

impl<M, O = Lsb0, T = usize> !Sync for BitPtrRange<M, O, T>

impl<M, O, T> Unpin for BitPtrRange<M, O, T> where
    M: Unpin,
    O: Unpin

impl<M, O, T> UnwindSafe for BitPtrRange<M, O, T> where
    M: UnwindSafe,
    O: UnwindSafe,
    T: RefUnwindSafe,
    <T as BitStore>::Mem: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T[src]

impl<T> FmtForward for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> Pipe for T where
    T: ?Sized
[src]

impl<T> Tap for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.