File: BitPtrRange.md

package info (click to toggle)
rust-coreutils 0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 505,620 kB
  • sloc: ansic: 103,594; asm: 28,570; sh: 8,910; python: 5,581; makefile: 472; cpp: 97; javascript: 72
file content (36 lines) | stat: -rw-r--r-- 1,404 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Bit-Pointer Range

This type is equivalent in purpose, but superior in functionality, to
`Range<BitPtr<M, T, O>>`. If the standard library stabilizes [`Step`], the trait
used to drive `Range` operations, then this type will likely be destroyed in
favor of an `impl Step for BitPtr` block and use of standard ranges.

Like [`Range`], this is a half-open set where the low bit-pointer selects the
first live bit in a span and the high bit-pointer selects the first dead bit
*after* the span.

This type is not capable of inspecting provenance, and has no requirement of its
own that both bit-pointers be derived from the same provenance region. It is
safe to construct and use with any pair of bit-pointers; however, the
bit-pointers it *produces* are, necessarily, `unsafe` to use.

## Original

[`Range<*bool>`][`Range`]

## Memory Representation

[`BitPtr`] is required to be `repr(packed)` in order to satisfy the [`BitRef`]
size optimizations. In order to stay minimally sized itself, this type has no
alignment requirement, and reading either bit-pointer *may* incur a misalignment
penalty. Reads are always safe and valid; they may merely be slow.

## Type Parameters

This takes the same type parameters as `BitPtr`, as it is simply a pair of
bit-pointers with range semantics.

[`BitPtr`]: crate::ptr::BitPtr
[`BitRef`]: crate::ptr::BitRef
[`Range`]: core::ops::Range
[`Step`]: core::iter::Step