Module

std::slice

source

Re-exported from core::slice.

Checked contiguous views over borrowed storage.

Types

SliceA checked view of len contiguous Ts in domain 'k.
ReadableA byte view together with the capability that permits reading it, as one value: what Eq, Hash, and Format instances take, since an instance head must be a named type.
SliceIter!A slice's elements in order, read under the capability a context lends (Access).

Traits

ReadBytesReading the bytes of a view S through the capability C.

Functions

slice_byte_atByte index of s, or None past its end, read with no capability.
byte_or_zeroByte index of a view read through its capability (ReadBytes::get), with 0u8 for out of range: a sentinel for scanners whose character-class tests already treat 0u8 as matching nothing.
bytes_eqContent equality of two byte views, of equal or different brands and capabilities.
bytes_cmpByte views in byte order, as unsigned values, a shorter prefix first.
bytes_eq_withinbytes_eq for two views of one domain, read through its one capability (which cannot be passed twice when it is linear); the last byte first, as bytes_eq compares.
bytes_cmp_withinbytes_cmp for two views of one domain, read through its one capability.
find_byteThe first index at or after start holding needle.
find_bytesThe first index at or after start where needle's bytes appear in bytes, both views read through the one capability.
rfind_byteThe last index holding needle.
hash_bytesWrites a byte view into state (core::hash's encoding of a byte string): its length, then its bytes eight to a word, little-endian, the last word padded with zeros.
byte_wordByte i of a byte view as a word (byte_or_zero).
word8Bytes i..i + 8 of a byte view as a little-endian word.

Instances

ReadBytes[Exclusive!['r], Slice[u8, 'r]]A byte slice is read through its domain's Exclusive!.
ReadBytes[Shared!['r, 'q], Slice[u8, 'r]]A byte slice is read through any node of its domain's shared-read tree.
Eq[Readable[C1, S1], Readable[C2, S2]]Readable views are equal when their bytes are (bytes_eq).
Hash[Readable[C, S]]A readable view hashes its bytes (hash_bytes).
Iterator[SliceIter![T, 'k, C, R] -> T]The slice's elements in order, read under the capability the iterator holds.

Function declarations

fn slice_byte_atsource

forall 'k.
unsafe fn slice_byte_at(s: Slice[u8, 'k], index: usize) -> Option[u8] { ... }

Byte index of s, or None past its end, read with no capability.

The shared body of the two instances below. Caller: holds a capability of s's brand for the call, since this reads its bytes with none of its own.

fn byte_or_zerosource

forall C, S where ReadBytes[C, S].
fn byte_or_zero(&cx: C, bytes: S, index: usize) -> u8 { ... }

Byte index of a view read through its capability (ReadBytes::get), with 0u8 for out of range: a sentinel for scanners whose character-class tests already treat 0u8 as matching nothing.

fn bytes_eqsource

forall C1, S1, C2, S2 where ReadBytes[C1, S1], ReadBytes[C2, S2], Copy[S1], Copy[S2].
fn bytes_eq(&left_cap: C1, left: S1, &right_cap: C2, right: S2) -> bool { ... }

Content equality of two byte views, of equal or different brands and capabilities. Two views of one exclusively owned domain cannot both take its single Exclusive!; split shared access first (Exclusive!::share, Shared!::split). Compares the last byte first: names of one length usually differ at the end (t_17 and t_18, a::b::x and a::b::y).

fn bytes_cmpsource

forall C1, S1, C2, S2 where ReadBytes[C1, S1], ReadBytes[C2, S2], Copy[S1], Copy[S2].
fn bytes_cmp(&left_cap: C1, left: S1, &right_cap: C2, right: S2) -> Order { ... }

Byte views in byte order, as unsigned values, a shorter prefix first. As with bytes_eq, each view is read through its own capability.

fn bytes_eq_withinsource

forall C, S where ReadBytes[C, S], Copy[S].
fn bytes_eq_within(&cx: C, left: S, right: S) -> bool { ... }

bytes_eq for two views of one domain, read through its one capability (which cannot be passed twice when it is linear); the last byte first, as bytes_eq compares.

fn bytes_cmp_withinsource

forall C, S where ReadBytes[C, S], Copy[S].
fn bytes_cmp_within(&cx: C, left: S, right: S) -> Order { ... }

bytes_cmp for two views of one domain, read through its one capability.

fn find_bytesource

forall C, S where ReadBytes[C, S], Copy[S].
fn find_byte(&cx: C, bytes: S, needle: u8, start: usize) -> Option[usize] { ... }

The first index at or after start holding needle. Every search takes what it looks for before where it starts: find_byte(&cx, bytes, needle, start), as Str::find and Str::find_byte do.

fn find_bytessource

forall C, S where ReadBytes[C, S], Copy[S].
fn find_bytes(&cx: C, bytes: S, needle: S, start: usize) -> Option[usize] { ... }

The first index at or after start where needle's bytes appear in bytes, both views read through the one capability. An empty needle is found at start itself, when start is within bytes.

fn rfind_bytesource

forall C, S where ReadBytes[C, S], Copy[S].
fn rfind_byte(&cx: C, bytes: S, needle: u8) -> Option[usize] { ... }

The last index holding needle.

fn hash_bytessource

forall C, S where ReadBytes[C, S], Copy[S].
fn hash_bytes(&cx: C, bytes: S, state: HashState) -> HashState { ... }

Writes a byte view into state (core::hash's encoding of a byte string): its length, then its bytes eight to a word, little-endian, the last word padded with zeros.

fn byte_wordsource

forall C, S where ReadBytes[C, S], Copy[S].
fn byte_word(&cx: C, bytes: S, i: usize) -> u64 { ... }

Byte i of a byte view as a word (byte_or_zero).

fn word8source

forall C, S where ReadBytes[C, S], Copy[S].
fn word8(&cx: C, bytes: S, i: usize) -> u64 { ... }

Bytes i..i + 8 of a byte view as a little-endian word.

Instance declarations

instance ReadBytes[Exclusive!['r], Slice[u8, 'r]]source

forall 'r.
instance ReadBytes[Exclusive!['r], Slice[u8, 'r]] { ... }

A byte slice is read through its domain's Exclusive!.

instance ReadBytes[Shared!['r, 'q], Slice[u8, 'r]]source

forall 'r, 'q.
instance ReadBytes[Shared!['r, 'q], Slice[u8, 'r]] { ... }

A byte slice is read through any node of its domain's shared-read tree.

instance Eq[Readable[C1, S1], Readable[C2, S2]]source

forall C1, S1, C2, S2 where ReadBytes[C1, S1], ReadBytes[C2, S2], Copy[S1], Copy[S2].
instance Eq[Readable[C1, S1], Readable[C2, S2]] { ... }

Readable views are equal when their bytes are (bytes_eq).

instance Hash[Readable[C, S]]source

forall C, S where ReadBytes[C, S], Copy[S].
instance Hash[Readable[C, S]] { ... }

A readable view hashes its bytes (hash_bytes).

instance Iterator[SliceIter![T, 'k, C, R] -> T]source

forall T, 'k, C, R where Copy[T], Sized[T].
instance Iterator[SliceIter![T, 'k, C, R] -> T] { ... }

The slice's elements in order, read under the capability the iterator holds.