lib/core
- struct PhysAddr
- struct VirtAddr
- struct Layout
- interface Allocator
- enum AsyncError
- struct Timer
- struct AsyncControl
- struct AsyncLeaf
- struct Raced
- struct TaskSet
- struct AsyncTasks
- struct AsyncTasksIn
- struct AsyncSignal
- enum LoadOrdering
- enum StoreOrdering
- enum Ordering
- struct AtomicU64
- struct AtomicU32
- struct AtomicU8
- struct AtomicUSize
- struct AtomicBool
- struct ByteOrder
- struct VectorBytes
- struct RawCell
- struct Cell
- struct RefCell
- struct RefCellTaking
- struct CellRef
- struct CellRefMut
- struct CStr
- interface DerivedEqual
- struct DerivedEqualElements
- struct TextWriter
- enum TextAlign
- struct Formatted
- interface AppendFormatted
- interface Iterator
- struct Volatile
- struct MmioPtr
- struct NumberParsing
- struct ResultMethods
- struct OptionalResults
- struct SliceHalves
- struct SliceHalvesMut
- struct SliceSplitting
- struct SliceAlgorithms
- struct VectorEditing
- struct TextHalves
- struct ByteHalves
- struct TextSplit
- struct ByteSplit
- struct TextSearch
- struct ByteSearch
struct PhysAddr
public struct PhysAddrA physical address.
PhysAddr.of
public fn of(bits: u64) -> PhysAddrThe address whose value is bits.
PhysAddr.bits
public fn bits(this) -> u64The address's value.
PhysAddr.offset
public fn offset(this, n: u64) -> PhysAddrThe address n bytes further on; panics if that overflows a u64.
struct VirtAddr
public struct VirtAddrA virtual address.
VirtAddr.of
public fn of(bits: u64) -> VirtAddrThe address whose value is bits.
VirtAddr.bits
public fn bits(this) -> u64The address's value.
VirtAddr.offset
public fn offset(this, n: u64) -> VirtAddrThe address n bytes further on; panics if that overflows a u64.
struct Layout
public struct LayoutThe size in bytes and the alignment (a power of two) of a block of memory.
interface Allocator
public interface Allocator {
fn allocate(borrow this, layout: Layout) -> Result<*mut u8, AllocError>;
unsafe fn deallocate(borrow this, p: *mut u8, layout: Layout);
}An allocator a Box<T, A> can use: a struct without fields that implements this (type-system.md §30.2).
enum AsyncError
public enum AsyncError {
Cancelled,
TimedOut,
Io(IoError),
}Why an async operation failed (type-system.md §40.4, §40.7).
struct Timer
public struct TimerTime for tasks: the monotonic clock in milliseconds.
Timer.now
public fn now() -> u64Milliseconds on the monotonic clock, from an arbitrary start. Safety: ceesafe_async_now only reads the clock.
Timer.sleep
public async fn sleep(ms: u64) -> Result<void, AsyncError>Waits at least ms milliseconds without blocking the thread: other tasks run meanwhile. Safety: ceesafe_async_wait_until only records the deadline for the executor. A cancelled task's sleep returns Err(AsyncError.Cancelled) at once (type-system.md §40.7).
struct AsyncControl
public struct AsyncControl<E>What Async.isCancelled() and Async.checkpoint(cancelled) call (type-system.md §40.4).
AsyncControl.isCancelled
public fn isCancelled() -> boolWhether the current task is cancelled and not shielded. Safety: ceesafe_async_status only reads the executor's state.
AsyncControl.enterShield
public fn enterShield(ms: u64)Async.shield's start (type-system.md §40.7). Safety: it only counts the current task's shields.
AsyncControl.leaveShield
public fn leaveShield()Async.shield's end. Safety: it only counts the current task's shields, after enterShield.
AsyncControl.checkpoint
public fn checkpoint(cancelled: E) -> Result<void, E>Err(cancelled) if the current task is cancelled and not shielded, else Ok.
struct AsyncLeaf
public struct AsyncLeafThe library's own steps for its waiting operations: not for programs (type-system.md §40.4).
AsyncLeaf.status
public fn status() -> Result<void, AsyncError>Err(Cancelled) if the current task is cancelled, Err(TimedOut) if its shield's time is up (type-system.md §40.7). Safety: ceesafe_async_status only reads the executor's state.
struct Raced
public struct Raced<T> {
public winner: u32;
public value: T;
public other: T?;
}Async.race's result (type-system.md §40.4): the child that returned Ok first (0 or 1), its value, and the other's value if it also returned Ok before it saw its cancellation.
struct TaskSet
@noncopy // the one handle of its record
public struct TaskSet<E: Copy>The set Async.tasks' body is given (ADR 0053 §3.1). The body, and the functions it passes the set to, start children with await set.spawn(async move () => …), which waits while the set's limit of children run, and set.trySpawn(async move () => …), which is false instead. A child owns what it captures: no loans, so it cannot capture the set (N0349). The calls are the checker's (src/check/async.cee): these are the steps it joins.
struct AsyncTasks
public struct AsyncTasks<E: Copy>await Async.tasks(limit, oom, async (set) => …) (ADR 0053): Async.tasksIn with the system heap.
AsyncTasks.run
@effectsOf(body)
public async fn run(
limit: u32,
oom: E,
body: borrow mut fn(borrow TaskSet<E>) -> Result<void, E>,
) -> Result<void, E>struct AsyncTasksIn
public struct AsyncTasksIn<E: Copy, A>await Async.tasksIn(alloc, limit, oom, async (set) => …) (ADR 0053): the body runs in the awaiting task, as the set's owner, with the set; then every child it started is waited for. The children's tasks and frames come from alloc's allocator type. The result is the body's error, else the first child's, else oom if a child's frame could not be allocated, else Ok. The body's error cancels the children; a child's error cancels no sibling.
AsyncTasksIn.run
@effectsOf(body)
public async fn run(
alloc: A,
limit: u32,
oom: E,
body: borrow mut fn(borrow TaskSet<E>) -> Result<void, E>,
) -> Result<void, E>Safety: the record is this frame's, which outlives every child: the set waits for them before it returns.
struct AsyncSignal
@noncopy // one signal, shared: a copy would never be raised
public struct AsyncSignalA one-shot wake-up from anywhere, to a task (ADR 0039): await signal.wait() parks the task until signal.raise(). raise has no effects, so an interrupt handler (@context(irq)) or another thread may call it, the way a driver tells the task waiting for its device. A raise before the wait is kept: the wait then returns at once. One task waits on a signal at a time.
AsyncSignal.create
public fn create() -> AsyncSignalA signal not raised.
AsyncSignal.constant
@constant
public fn constant() -> AsyncSignalThe same as create, in a static's initialiser (type-system.md §39.4): static READY: AsyncSignal = AsyncSignal.constant();, which an interrupt handler can raise.
AsyncSignal.raise
@effects()
public fn raise(borrow this)Raises the signal: the task waiting on it, if any, runs again. Safety: the runtime changes the record atomically, and only wakes the task it names.
AsyncSignal.wait
public async fn wait(borrow this) -> Result<void, AsyncError>Waits until the signal is raised, then lowers it. A cancelled task returns Err(AsyncError.Cancelled) and no longer waits (type-system.md §40.7). Safety: the record names this task only while it waits here; ceesafe_async_signal_forget takes it out.
enum LoadOrdering
public enum LoadOrdering {
Relaxed,
Acquire,
SequentiallyConsistent,
}The ordering of an atomic load (ADR 0021): C11's memory_order_relaxed, _acquire and _seq_cst.
enum StoreOrdering
public enum StoreOrdering {
Relaxed,
Release,
SequentiallyConsistent,
}The ordering of an atomic store: C11's memory_order_relaxed, _release and _seq_cst.
enum Ordering
public enum Ordering {
Relaxed,
Acquire,
Release,
AcquireRelease,
SequentiallyConsistent,
}The ordering of an atomic read-modify-write (swap, compare-exchange, add, subtract): C11's memory_order_relaxed, _acquire, _release, _acq_rel and _seq_cst. A compare-exchange that fails orders as a load: AcquireRelease as Acquire, Release as Relaxed, the others as themselves.
struct AtomicU64
@threadSafe
@noncopy
public struct AtomicU64A u64 that threads may read and change at once: every operation is atomic and sequentially consistent.
AtomicU64.create
public fn create(value: u64) -> AtomicU64A new atomic holding value.
AtomicU64.constant
@constant
public fn constant(value: u64) -> AtomicU64The same as create, in a static's initialiser (type-system.md §39.4): static N: AtomicU64 = AtomicU64.constant(0);.
AtomicU64.load
public fn load(borrow this) -> u64Safety: the runtime accesses value only atomically, and safe code reaches it only through these methods.
AtomicU64.store
public fn store(borrow this, value: u64)Safety: as load.
AtomicU64.swap
public fn swap(borrow this, value: u64) -> u64Safety: as load.
AtomicU64.compareExchange
public fn compareExchange(borrow this, expected: u64, desired: u64) -> Result<u64, u64>Ok(the old value) if it was expected and is now desired; else Err(the value it has). Safety: as load.
AtomicU64.fetchAdd
public fn fetchAdd(borrow this, value: u64) -> u64Adds, wrapping; returns the old value. Safety: as load.
AtomicU64.fetchSub
public fn fetchSub(borrow this, value: u64) -> u64Subtracts, wrapping; returns the old value. Safety: as load.
AtomicU64.fetchOr
public fn fetchOr(borrow this, value: u64) -> u64Sets the bits of value; the value before (ADR 0041). Safety: as load.
AtomicU64.fetchAnd
public fn fetchAnd(borrow this, value: u64) -> u64Keeps only the bits of value; the value before (ADR 0041). Safety: as load.
AtomicU64.loadWith
public fn loadWith(borrow this, order: LoadOrdering) -> u64load, with an ordering (ADR 0021). Safety: as load.
AtomicU64.storeWith
public fn storeWith(borrow this, value: u64, order: StoreOrdering)store, with an ordering. Safety: as load.
AtomicU64.swapWith
public fn swapWith(borrow this, value: u64, order: Ordering) -> u64swap, with an ordering. Safety: as load.
AtomicU64.compareExchangeWith
public fn compareExchangeWith(borrow this, expected: u64, desired: u64, order: Ordering) -> Result<u64, u64>compareExchange, with an ordering; a failure orders as Ordering says. Safety: as load.
AtomicU64.fetchAddWith
public fn fetchAddWith(borrow this, value: u64, order: Ordering) -> u64fetchAdd, with an ordering. Safety: as load.
AtomicU64.fetchSubWith
public fn fetchSubWith(borrow this, value: u64, order: Ordering) -> u64fetchSub, with an ordering. Safety: as load.
AtomicU64.fetchOrWith
public fn fetchOrWith(borrow this, value: u64, order: Ordering) -> u64fetchOr, with an ordering. Safety: as load.
AtomicU64.fetchAndWith
public fn fetchAndWith(borrow this, value: u64, order: Ordering) -> u64fetchAnd, with an ordering. Safety: as load.
struct AtomicU32
@threadSafe
@noncopy
public struct AtomicU32A u32 that threads may read and change at once, as AtomicU64.
AtomicU32.create
public fn create(value: u32) -> AtomicU32A new atomic holding value.
AtomicU32.constant
@constant
public fn constant(value: u32) -> AtomicU32The same as create, in a static's initialiser (type-system.md §39.4): static N: AtomicU32 = AtomicU32.constant(0);.
AtomicU32.load
public fn load(borrow this) -> u32Safety: as AtomicU64.load.
AtomicU32.store
public fn store(borrow this, value: u32)Safety: as AtomicU64.load.
AtomicU32.swap
public fn swap(borrow this, value: u32) -> u32Safety: as AtomicU64.load.
AtomicU32.compareExchange
public fn compareExchange(borrow this, expected: u32, desired: u32) -> Result<u32, u32>Safety: as AtomicU64.load.
AtomicU32.fetchAdd
public fn fetchAdd(borrow this, value: u32) -> u32Safety: as AtomicU64.load.
AtomicU32.fetchSub
public fn fetchSub(borrow this, value: u32) -> u32Safety: as AtomicU64.load.
AtomicU32.fetchOr
public fn fetchOr(borrow this, value: u32) -> u32Sets the bits of value; the value before (ADR 0041). Safety: as load.
AtomicU32.fetchAnd
public fn fetchAnd(borrow this, value: u32) -> u32Keeps only the bits of value; the value before (ADR 0041). Safety: as load.
AtomicU32.loadWith
public fn loadWith(borrow this, order: LoadOrdering) -> u32load, with an ordering (ADR 0021). Safety: as load.
AtomicU32.storeWith
public fn storeWith(borrow this, value: u32, order: StoreOrdering)store, with an ordering. Safety: as load.
AtomicU32.swapWith
public fn swapWith(borrow this, value: u32, order: Ordering) -> u32swap, with an ordering. Safety: as load.
AtomicU32.compareExchangeWith
public fn compareExchangeWith(borrow this, expected: u32, desired: u32, order: Ordering) -> Result<u32, u32>compareExchange, with an ordering; a failure orders as Ordering says. Safety: as load.
AtomicU32.fetchAddWith
public fn fetchAddWith(borrow this, value: u32, order: Ordering) -> u32fetchAdd, with an ordering. Safety: as load.
AtomicU32.fetchSubWith
public fn fetchSubWith(borrow this, value: u32, order: Ordering) -> u32fetchSub, with an ordering. Safety: as load.
AtomicU32.fetchOrWith
public fn fetchOrWith(borrow this, value: u32, order: Ordering) -> u32fetchOr, with an ordering. Safety: as load.
AtomicU32.fetchAndWith
public fn fetchAndWith(borrow this, value: u32, order: Ordering) -> u32fetchAnd, with an ordering. Safety: as load.
struct AtomicU8
@threadSafe
@noncopy
public struct AtomicU8A u8 that threads may read and change at once, as AtomicU32: for a byte member that C reads and writes atomically (ADR 0080 §3.5), such as a process's flag.
AtomicU8.create
public fn create(value: u8) -> AtomicU8A new atomic holding value.
AtomicU8.constant
@constant
public fn constant(value: u8) -> AtomicU8The same as create, in a static's initialiser (type-system.md §39.4).
AtomicU8.load
public fn load(borrow this) -> u8Safety: as AtomicU64.load.
AtomicU8.store
public fn store(borrow this, value: u8)Safety: as AtomicU64.load.
AtomicU8.swap
public fn swap(borrow this, value: u8) -> u8Safety: as AtomicU64.load.
AtomicU8.compareExchange
public fn compareExchange(borrow this, expected: u8, desired: u8) -> Result<u8, u8>Safety: as AtomicU64.load.
AtomicU8.loadWith
public fn loadWith(borrow this, order: LoadOrdering) -> u8load, with an ordering (ADR 0021). Safety: as load.
AtomicU8.storeWith
public fn storeWith(borrow this, value: u8, order: StoreOrdering)store, with an ordering. Safety: as load.
struct AtomicUSize
@threadSafe
@noncopy
public struct AtomicUSizeA usize that threads may read and change at once, as AtomicU64 (usize is 64 bits on every target, §29.3).
AtomicUSize.create
public fn create(value: usize) -> AtomicUSizeA new atomic holding value.
AtomicUSize.constant
@constant
public fn constant(value: usize) -> AtomicUSizeThe same as create, in a static's initialiser (type-system.md §39.4).
AtomicUSize.load
public fn load(borrow this) -> usizeThe value, sequentially consistent.
AtomicUSize.store
public fn store(borrow this, value: usize)Stores value, sequentially consistent.
AtomicUSize.swap
public fn swap(borrow this, value: usize) -> usizeStores value and returns the old value, sequentially consistent.
AtomicUSize.compareExchange
public fn compareExchange(borrow this, expected: usize, desired: usize) -> Result<usize, usize>Ok(the old value) if it was expected and is now desired; else Err(the value it has).
AtomicUSize.fetchAdd
public fn fetchAdd(borrow this, value: usize) -> usizeAdds, wrapping; returns the old value.
AtomicUSize.fetchSub
public fn fetchSub(borrow this, value: usize) -> usizeSubtracts, wrapping; returns the old value.
AtomicUSize.fetchOr
public fn fetchOr(borrow this, value: usize) -> usizeAs fetchOr.
AtomicUSize.fetchAnd
public fn fetchAnd(borrow this, value: usize) -> usizeAs fetchAnd.
AtomicUSize.loadWith
public fn loadWith(borrow this, order: LoadOrdering) -> usizeAs load, with order.
AtomicUSize.storeWith
public fn storeWith(borrow this, value: usize, order: StoreOrdering)As store, with order.
AtomicUSize.swapWith
public fn swapWith(borrow this, value: usize, order: Ordering) -> usizeAs swap, with order.
AtomicUSize.compareExchangeWith
public fn compareExchangeWith(
borrow this,
expected: usize,
desired: usize,
order: Ordering,
) -> Result<usize, usize>As compareExchange, with order (a failure orders as a load, §38.3).
AtomicUSize.fetchAddWith
public fn fetchAddWith(borrow this, value: usize, order: Ordering) -> usizeAs fetchAdd, with order.
AtomicUSize.fetchSubWith
public fn fetchSubWith(borrow this, value: usize, order: Ordering) -> usizeAs fetchSub, with order.
AtomicUSize.fetchOrWith
public fn fetchOrWith(borrow this, value: usize, order: Ordering) -> usizeAs fetchOrWith.
AtomicUSize.fetchAndWith
public fn fetchAndWith(borrow this, value: usize, order: Ordering) -> usizeAs fetchAndWith.
struct AtomicBool
@threadSafe
@noncopy
public struct AtomicBoolA bool that threads may read and change at once.
AtomicBool.create
public fn create(value: bool) -> AtomicBoolA new atomic holding value.
AtomicBool.constant
@constant
public fn constant(value: bool) -> AtomicBoolThe same as create, in a static's initialiser (type-system.md §39.4).
AtomicBool.load
public fn load(borrow this) -> boolThe value, sequentially consistent.
AtomicBool.store
public fn store(borrow this, value: bool)Stores value, sequentially consistent.
AtomicBool.swap
public fn swap(borrow this, value: bool) -> boolStores value and returns the old value, sequentially consistent.
AtomicBool.compareExchange
public fn compareExchange(borrow this, expected: bool, desired: bool) -> Result<bool, bool>Ok(the old value) if it was expected and is now desired; else Err(the value it has).
AtomicBool.loadWith
public fn loadWith(borrow this, order: LoadOrdering) -> boolAs load, with order.
AtomicBool.storeWith
public fn storeWith(borrow this, value: bool, order: StoreOrdering)As store, with order.
AtomicBool.swapWith
public fn swapWith(borrow this, value: bool, order: Ordering) -> boolAs swap, with order.
AtomicBool.compareExchangeWith
public fn compareExchangeWith(borrow this, expected: bool, desired: bool, order: Ordering) -> Result<bool, bool>As compareExchange, with order (a failure orders as a load, §38.3).
struct ByteOrder
public struct ByteOrderReading and writing integers in a byte order: static functions; the struct has no fields and is never made.
ByteOrder.readU8BE
public fn readU8BE(s: Slice<u8>, at: usize) -> u8The u8 in the 1 byte at at, big-endian.
ByteOrder.readI8BE
public fn readI8BE(s: Slice<u8>, at: usize) -> i8The i8 in the 1 byte at at, big-endian, in two's complement.
ByteOrder.writeU8BE
public fn writeU8BE(s: SliceMut<u8>, at: usize, x: u8)Writes x to the 1 byte at at, big-endian.
ByteOrder.writeI8BE
public fn writeI8BE(s: SliceMut<u8>, at: usize, x: i8)Writes x to the 1 byte at at, big-endian, in two's complement.
ByteOrder.readU8LE
public fn readU8LE(s: Slice<u8>, at: usize) -> u8The u8 in the 1 byte at at, little-endian.
ByteOrder.readI8LE
public fn readI8LE(s: Slice<u8>, at: usize) -> i8The i8 in the 1 byte at at, little-endian, in two's complement.
ByteOrder.writeU8LE
public fn writeU8LE(s: SliceMut<u8>, at: usize, x: u8)Writes x to the 1 byte at at, little-endian.
ByteOrder.writeI8LE
public fn writeI8LE(s: SliceMut<u8>, at: usize, x: i8)Writes x to the 1 byte at at, little-endian, in two's complement.
ByteOrder.readU16BE
public fn readU16BE(s: Slice<u8>, at: usize) -> u16The u16 in the 2 bytes at at, big-endian.
ByteOrder.readI16BE
public fn readI16BE(s: Slice<u8>, at: usize) -> i16The i16 in the 2 bytes at at, big-endian, in two's complement.
ByteOrder.writeU16BE
public fn writeU16BE(s: SliceMut<u8>, at: usize, x: u16)Writes x to the 2 bytes at at, big-endian.
ByteOrder.writeI16BE
public fn writeI16BE(s: SliceMut<u8>, at: usize, x: i16)Writes x to the 2 bytes at at, big-endian, in two's complement.
ByteOrder.readU16LE
public fn readU16LE(s: Slice<u8>, at: usize) -> u16The u16 in the 2 bytes at at, little-endian.
ByteOrder.readI16LE
public fn readI16LE(s: Slice<u8>, at: usize) -> i16The i16 in the 2 bytes at at, little-endian, in two's complement.
ByteOrder.writeU16LE
public fn writeU16LE(s: SliceMut<u8>, at: usize, x: u16)Writes x to the 2 bytes at at, little-endian.
ByteOrder.writeI16LE
public fn writeI16LE(s: SliceMut<u8>, at: usize, x: i16)Writes x to the 2 bytes at at, little-endian, in two's complement.
ByteOrder.readU32BE
public fn readU32BE(s: Slice<u8>, at: usize) -> u32The u32 in the 4 bytes at at, big-endian.
ByteOrder.readI32BE
public fn readI32BE(s: Slice<u8>, at: usize) -> i32The i32 in the 4 bytes at at, big-endian, in two's complement.
ByteOrder.writeU32BE
public fn writeU32BE(s: SliceMut<u8>, at: usize, x: u32)Writes x to the 4 bytes at at, big-endian.
ByteOrder.writeI32BE
public fn writeI32BE(s: SliceMut<u8>, at: usize, x: i32)Writes x to the 4 bytes at at, big-endian, in two's complement.
ByteOrder.readU32LE
public fn readU32LE(s: Slice<u8>, at: usize) -> u32The u32 in the 4 bytes at at, little-endian.
ByteOrder.readI32LE
public fn readI32LE(s: Slice<u8>, at: usize) -> i32The i32 in the 4 bytes at at, little-endian, in two's complement.
ByteOrder.writeU32LE
public fn writeU32LE(s: SliceMut<u8>, at: usize, x: u32)Writes x to the 4 bytes at at, little-endian.
ByteOrder.writeI32LE
public fn writeI32LE(s: SliceMut<u8>, at: usize, x: i32)Writes x to the 4 bytes at at, little-endian, in two's complement.
ByteOrder.readU64BE
public fn readU64BE(s: Slice<u8>, at: usize) -> u64The u64 in the 8 bytes at at, big-endian.
ByteOrder.readI64BE
public fn readI64BE(s: Slice<u8>, at: usize) -> i64The i64 in the 8 bytes at at, big-endian, in two's complement.
ByteOrder.writeU64BE
public fn writeU64BE(s: SliceMut<u8>, at: usize, x: u64)Writes x to the 8 bytes at at, big-endian.
ByteOrder.writeI64BE
public fn writeI64BE(s: SliceMut<u8>, at: usize, x: i64)Writes x to the 8 bytes at at, big-endian, in two's complement.
ByteOrder.readU64LE
public fn readU64LE(s: Slice<u8>, at: usize) -> u64The u64 in the 8 bytes at at, little-endian.
ByteOrder.readI64LE
public fn readI64LE(s: Slice<u8>, at: usize) -> i64The i64 in the 8 bytes at at, little-endian, in two's complement.
ByteOrder.writeU64LE
public fn writeU64LE(s: SliceMut<u8>, at: usize, x: u64)Writes x to the 8 bytes at at, little-endian.
ByteOrder.writeI64LE
public fn writeI64LE(s: SliceMut<u8>, at: usize, x: i64)Writes x to the 8 bytes at at, little-endian, in two's complement.
struct VectorBytes
public struct VectorBytesAppending integers to a byte vector in a byte order: v.pushBE(x) and v.pushLE(x) (ADR 0071 §2.2). Each is one extend of the bytes, so it grows the vector at most once and leaves it unchanged if that fails. A vector's allocator is SystemHeap or FailingAllocator (type-system.md §23.1); the …Failing functions are the latter's.
VectorBytes.pushU8BE
public fn pushU8BE(v: borrow mut Vector<u8>, x: u8) -> Result<void, AllocError>Appends x as 1 byte, big-endian.
VectorBytes.pushI8BE
public fn pushI8BE(v: borrow mut Vector<u8>, x: i8) -> Result<void, AllocError>Appends x as 1 byte, big-endian, in two's complement.
VectorBytes.pushU8LE
public fn pushU8LE(v: borrow mut Vector<u8>, x: u8) -> Result<void, AllocError>Appends x as 1 byte, little-endian.
VectorBytes.pushI8LE
public fn pushI8LE(v: borrow mut Vector<u8>, x: i8) -> Result<void, AllocError>Appends x as 1 byte, little-endian, in two's complement.
VectorBytes.pushU16BE
public fn pushU16BE(v: borrow mut Vector<u8>, x: u16) -> Result<void, AllocError>Appends x as 2 bytes, big-endian.
VectorBytes.pushI16BE
public fn pushI16BE(v: borrow mut Vector<u8>, x: i16) -> Result<void, AllocError>Appends x as 2 bytes, big-endian, in two's complement.
VectorBytes.pushU16LE
public fn pushU16LE(v: borrow mut Vector<u8>, x: u16) -> Result<void, AllocError>Appends x as 2 bytes, little-endian.
VectorBytes.pushI16LE
public fn pushI16LE(v: borrow mut Vector<u8>, x: i16) -> Result<void, AllocError>Appends x as 2 bytes, little-endian, in two's complement.
VectorBytes.pushU32BE
public fn pushU32BE(v: borrow mut Vector<u8>, x: u32) -> Result<void, AllocError>Appends x as 4 bytes, big-endian.
VectorBytes.pushI32BE
public fn pushI32BE(v: borrow mut Vector<u8>, x: i32) -> Result<void, AllocError>Appends x as 4 bytes, big-endian, in two's complement.
VectorBytes.pushU32LE
public fn pushU32LE(v: borrow mut Vector<u8>, x: u32) -> Result<void, AllocError>Appends x as 4 bytes, little-endian.
VectorBytes.pushI32LE
public fn pushI32LE(v: borrow mut Vector<u8>, x: i32) -> Result<void, AllocError>Appends x as 4 bytes, little-endian, in two's complement.
VectorBytes.pushU64BE
public fn pushU64BE(v: borrow mut Vector<u8>, x: u64) -> Result<void, AllocError>Appends x as 8 bytes, big-endian.
VectorBytes.pushI64BE
public fn pushI64BE(v: borrow mut Vector<u8>, x: i64) -> Result<void, AllocError>Appends x as 8 bytes, big-endian, in two's complement.
VectorBytes.pushU64LE
public fn pushU64LE(v: borrow mut Vector<u8>, x: u64) -> Result<void, AllocError>Appends x as 8 bytes, little-endian.
VectorBytes.pushI64LE
public fn pushI64LE(v: borrow mut Vector<u8>, x: i64) -> Result<void, AllocError>Appends x as 8 bytes, little-endian, in two's complement.
VectorBytes.pushU8BEFailing
public fn pushU8BEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: u8) -> Result<void, AllocError>Appends x as 1 byte, big-endian.
VectorBytes.pushI8BEFailing
public fn pushI8BEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: i8) -> Result<void, AllocError>Appends x as 1 byte, big-endian, in two's complement.
VectorBytes.pushU8LEFailing
public fn pushU8LEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: u8) -> Result<void, AllocError>Appends x as 1 byte, little-endian.
VectorBytes.pushI8LEFailing
public fn pushI8LEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: i8) -> Result<void, AllocError>Appends x as 1 byte, little-endian, in two's complement.
VectorBytes.pushU16BEFailing
public fn pushU16BEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: u16) -> Result<void, AllocError>Appends x as 2 bytes, big-endian.
VectorBytes.pushI16BEFailing
public fn pushI16BEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: i16) -> Result<void, AllocError>Appends x as 2 bytes, big-endian, in two's complement.
VectorBytes.pushU16LEFailing
public fn pushU16LEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: u16) -> Result<void, AllocError>Appends x as 2 bytes, little-endian.
VectorBytes.pushI16LEFailing
public fn pushI16LEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: i16) -> Result<void, AllocError>Appends x as 2 bytes, little-endian, in two's complement.
VectorBytes.pushU32BEFailing
public fn pushU32BEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: u32) -> Result<void, AllocError>Appends x as 4 bytes, big-endian.
VectorBytes.pushI32BEFailing
public fn pushI32BEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: i32) -> Result<void, AllocError>Appends x as 4 bytes, big-endian, in two's complement.
VectorBytes.pushU32LEFailing
public fn pushU32LEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: u32) -> Result<void, AllocError>Appends x as 4 bytes, little-endian.
VectorBytes.pushI32LEFailing
public fn pushI32LEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: i32) -> Result<void, AllocError>Appends x as 4 bytes, little-endian, in two's complement.
VectorBytes.pushU64BEFailing
public fn pushU64BEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: u64) -> Result<void, AllocError>Appends x as 8 bytes, big-endian.
VectorBytes.pushI64BEFailing
public fn pushI64BEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: i64) -> Result<void, AllocError>Appends x as 8 bytes, big-endian, in two's complement.
VectorBytes.pushU64LEFailing
public fn pushU64LEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: u64) -> Result<void, AllocError>Appends x as 8 bytes, little-endian.
VectorBytes.pushI64LEFailing
public fn pushI64LEFailing(v: borrow mut Vector<u8, FailingAllocator>, x: i64) -> Result<void, AllocError>Appends x as 8 bytes, little-endian, in two's complement.
VectorBytes.appendHex
public fn appendHex(v: borrow mut Vector<u8>, value: u64, minWidth: u32, upper: bool) -> Result<void, AllocError>Appends value in hexadecimal, at least minWidth digits, uppercase when upper (ADR 0087 §2.9).
VectorBytes.appendOctal
public fn appendOctal(v: borrow mut Vector<u8>, value: u64) -> Result<void, AllocError>Appends value in octal (ADR 0087 §2.9).
VectorBytes.appendFixed
public fn appendFixed(v: borrow mut Vector<u8>, value: f64, digits: u32) -> Result<void, AllocError>Appends value with digits digits after the point, rounded half to even (ADR 0087 §2.9).
VectorBytes.appendPadded
public fn appendPadded(
v: borrow mut Vector<u8>,
text: StringView,
width: usize,
align: TextAlign,
fill: u32,
) -> Result<void, AllocError>Appends text in a field width characters wide, filled with fill where align puts it (ADR 0087 §2.9).
struct RawCell
@interiorMutable
@noncopy
public struct RawCell<T>The primitive (§41.1): a T that may be read and written through pointer() while shared loans of the cell, or of a value holding it, are live. It has T's size and alignment. T may not hold loans (N0351).
RawCell.create
public fn create(value: T) -> RawCell<T>A cell holding value.
RawCell.pointer
public fn pointer(borrow this) -> *mut TThe contents' address: safe to take, unsafe to use. Unsafe code must not make two live borrow mut T from it, nor write while a borrow T it made is live (unsafe.md §2).
RawCell.getMut
public fn getMut(borrow mut this) -> borrow mut TThe contents, for as long as the cell is borrowed exclusively: no other loan of it can be live.
RawCell.intoInner
public fn intoInner(this) -> TThe contents, the cell consumed.
struct Cell
public struct Cell<T: Copy>A Copy value that may be read and replaced through a shared reference (§41.2): get copies it out, set stores a new one. No method lends a reference to the contents, so no change can be seen through a stale one, and a call between two methods (a re-entrant callback) is harmless. == and != compare the contents when T has them.
Cell.create
public fn create(value: T) -> Cell<T>A cell holding value.
Cell.get
public fn get(borrow this) -> TA copy of the contents. Safety: no reference to the contents is ever lent, so nothing writes them during the read; T is Copy.
Cell.set
public fn set(borrow this, value: T)Stores value; the old contents need no drop (T is Copy), so no user code runs. Safety: as get; nothing reads the contents during the write.
Cell.replace
public fn replace(borrow this, value: T) -> TStores value and returns the old contents. Safety: as set.
Cell.getMut
public fn getMut(borrow mut this) -> borrow mut TThe contents, for as long as the cell is borrowed exclusively.
Cell.intoInner
public fn intoInner(this) -> TThe contents, the cell consumed.
struct RefCell
public struct RefCell<T>A value lent through a shared reference with checked access (§41.3): any number of read guards, or one write guard, at a time. A conflict panics ("cell already borrowed"); tryRead and tryWrite return null instead. The state is one word: 0 free, n > 0 readers, -1 writing.
RefCell.create
public fn create(value: T) -> RefCell<T>A cell holding value, free.
RefCell.read
public fn read(borrow this) -> CellRef<T>Shared access until the guard is dropped; panics while a write guard is live.
RefCell.tryRead
public fn tryRead(borrow this) -> CellRef<T>?As read, or null while a write guard is live.
RefCell.write
public fn write(borrow this) -> CellRefMut<T>Exclusive access until the guard is dropped; panics while any guard is live.
RefCell.tryWrite
public fn tryWrite(borrow this) -> CellRefMut<T>?As write, or null while any guard is live.
RefCell.replace
public fn replace(borrow this, value: T) -> TStores value and returns the old contents, moved out before the return: their drop runs in the caller, with no guard live. Panics while any guard is live. Safety: no guard is live, so no reference to the contents is; the old value is read out before the write.
RefCell.getMut
public fn getMut(borrow mut this) -> borrow mut TThe contents, for as long as the cell is borrowed exclusively: no guard can be live.
RefCell.intoInner
public fn intoInner(this) -> TThe contents, the cell consumed.
struct RefCellTaking
public struct RefCellTaking<T>RefCell.take on a RefCell<T?> (§41.3): the contents, leaving null.
RefCellTaking.take
public fn take(cell: borrow RefCell<T?>) -> T?Panics while any guard is live, as replace.
struct CellRef
public struct CellRef<region r, T> {
drop { … }
}A read guard of a RefCell (§41.3): data() lends the contents shared; dropping it gives the access back.
CellRef.data
public fn data(borrow this) -> borrow TThe contents, for as long as the guard is borrowed.
struct CellRefMut
public struct CellRefMut<region r, T> {
drop { … }
}A write guard of a RefCell (§41.3): data() lends the contents exclusively; dropping it gives the access back.
CellRefMut.data
public fn data(borrow mut this) -> borrow mut TThe contents, for as long as the guard is borrowed exclusively. Safety: the guard set the state to -1, so no other guard is live and none can be made while it is; the loan ends before the guard's drop gives the access back (a RawCell's contents may change while the cell is shared, type-system.md §41.1).
struct CStr
public struct CStr<region r>A view of UTF-8 text with a NUL byte after its end, valid for region r as a StringView<r> is: what a C function taking a const char * needs. Copy; a field of this type needs a region parameter, as a view's does.
CStr.fromBytesWithNul
public fn fromBytesWithNul(b: Slice<r, u8>) -> CStr<r>?Bytes ending in a NUL that is their only one, as valid UTF-8 text before it; else null.
CStr.ptr
public fn ptr(borrow this) -> *CCharThe address of the first byte, for C: the text is followed by its NUL.
CStr.view
public fn view(borrow this) -> StringView<r>The text, without the NUL.
CStr.length
public fn length(borrow this) -> usizeThe text's length in bytes, without the NUL.
CStr.bytesWithNul
public fn bytesWithNul(borrow this) -> Slice<r, u8>The text and its NUL: length + 1 bytes.
interface DerivedEqual
public interface DerivedEqual<T> {
fn derivedEqual(borrow this, other: borrow T) -> bool;
}The equality @derive(Equal) gives a struct or enum: a == b on the type calls a.derivedEqual(b), and a != b negates it. Only the compiler implements it: an impl written by hand is N0290, so == keeps one meaning (language-spec.md §6).
struct DerivedEqualElements
public struct DerivedEqualElements<T: DerivedEqual<T>>== on slices, arrays and vectors of a type @derive(Equal) gave equality (ADR 0087 §2.3): the same length, and each element equal to the other's, in order. The compiler calls it for a == b; a program has no need to.
DerivedEqualElements.equal
public fn equal(a: Slice<T>, b: Slice<T>) -> boolWhether a and b have the same length and equal elements.
struct TextWriter
public struct TextWriter<region r>A writer of text into a caller's byte buffer, as C's snprintf writes: what does not fit is cut off, the text is always zero-terminated in a buffer of at least one byte (so cText can be handed to C), and wanted counts every byte asked for, as snprintf's result does, so a caller can tell that the text was cut.
TextWriter.create
public fn create(buffer: SliceMut<r, u8>) -> TextWriter<r>A writer at the start of buffer, which it empties (a zero first byte, if it has one).
TextWriter.byte
public fn byte(borrow mut this, b: u8)Appends one byte.
TextWriter.bytes
public fn bytes(borrow mut this, data: Slice<u8>)Appends bytes.
TextWriter.text
public fn text(borrow mut this, s: StringView)Appends text.
TextWriter.decimal
public fn decimal(borrow mut this, value: u64)Appends an unsigned integer in decimal.
TextWriter.signed
public fn signed(borrow mut this, value: i64)Appends a signed integer in decimal, with a - if it is negative.
TextWriter.hex
public fn hex(borrow mut this, value: u64, width: u32)Appends an unsigned integer in lowercase hexadecimal, with at least width digits (zeros before it), as %0*llx; no 0x.
TextWriter.written
public fn written(borrow this) -> Slice<u8>The bytes written, without the terminating zero.
TextWriter.length
public fn length(borrow this) -> usizeHow many bytes were written (at most the buffer's length less one).
TextWriter.wanted
public fn wanted(borrow this) -> usizeHow many bytes were asked for: more than length() when the text was cut, as snprintf's result.
TextWriter.truncated
public fn truncated(borrow this) -> boolWhether some text did not fit.
TextWriter.cText
public fn cText(borrow this) -> *CCharThe text as a zero-terminated C string, valid while the writer's buffer is. An empty buffer, which can hold no terminator, gives an empty string that is not in it.
enum TextAlign
public enum TextAlign {
Left,
Right,
Center,
}Where appendPadded puts text in a wider field (ADR 0087 §2.9): Rust's {:<w}, {:>w} and {:^w}. A centred text's extra fill character goes after it.
struct Formatted
public struct FormattedThe formatting helpers of String and VectorBytes (ADR 0087 §2.9): what Rust's {:x}, {:08X}, {:o}, {:.3} and {:>8} write. Each appends to a byte vector; static functions, the struct is never made.
Formatted.hex
public fn hex(out: borrow mut Vector<u8>, value: u64, minWidth: u32, upper: bool) -> Result<void, AllocError>value in hexadecimal, at least minWidth digits (zeros before it), uppercase when upper; no 0x.
Formatted.octal
public fn octal(out: borrow mut Vector<u8>, value: u64) -> Result<void, AllocError>value in octal; no 0o.
Formatted.fixed
public fn fixed(out: borrow mut Vector<u8>, value: f64, digits: u32) -> Result<void, AllocError>value in decimal with exactly digits digits after the point (none, and no point, for 0), rounded half to even on its exact binary value, as Rust's {:.N} and C's %.Nf round; NaN, inf and -inf as Rust writes them. A negative zero keeps its sign.
Formatted.padded
public fn padded(
out: borrow mut Vector<u8>,
text: StringView,
width: usize,
align: TextAlign,
fill: u32,
) -> Result<void, AllocError>text in a field of width characters (Unicode scalar values, as Rust counts them), filled with the character fill on the side align leaves; text at least as wide is appended as it is.
interface AppendFormatted
public interface AppendFormatted {
fn appendHex(borrow mut this, value: u64, minWidth: u32, upper: bool) -> Result<void, AllocError>;
fn appendOctal(borrow mut this, value: u64) -> Result<void, AllocError>;
fn appendFixed(borrow mut this, value: f64, digits: u32) -> Result<void, AllocError>;
fn appendPadded(borrow mut this, text: StringView, width: usize, align: TextAlign, fill: u32) -> Result<void, AllocError>;
}s.appendHex(…) and the other helpers (ADR 0087 §2.9), through Formatted: implemented here for a Vector<u8>, and in lib/std for a String. Each appends ASCII, or for appendPadded the text and its fill, so a string stays UTF-8.
interface Iterator
public interface Iterator<T> {
fn next(borrow mut this) -> T?;
}A source of values, one at a time: next() gives each, then null. for (x in e) calls it on a struct that has such a method (the shape is enough, ADR 0074 §2.8), on a type parameter bounded by Iterator<T>, and on a borrow mut dyn Iterator<T> or a Box<dyn Iterator<T>> (type-system.md §16.4). The item is a parameter, so callers fix it directly (I: Iterator<u8>) and dyn Iterator<T> has a table.
struct Volatile
@noncopy
public struct Volatile<T: Copy>A cell read and written only by volatile accesses: a hardware register, or memory shared with a device. Not Copy: a copy would read the register with an ordinary access, once, instead of each time it is used.
Volatile.read
public fn read(borrow this) -> TSafety: this.value is a live, aligned T (it is a field), and the read is a single volatile access.
Volatile.write
public fn write(borrow mut this, v: T)Safety: as read; borrow mut this makes the write exclusive.
struct MmioPtr
@noncopy
public struct MmioPtr<T>The address of a memory-mapped T, typically a @repr(C) struct of Volatile registers. Not Copy: two copies would be two owners of the same registers.
MmioPtr.at
public unsafe fn at(address: usize) -> MmioPtr<T>Safety: address is mapped, aligned for T, and no other MmioPtr or reference aliases the registers.
MmioPtr.get
public fn get(borrow this) -> borrow TSafety: at's contract makes base a live T reached only through this value; the result borrows this.
MmioPtr.getMut
public fn getMut(borrow mut this) -> borrow mut TSafety: as get; borrow mut this makes the access exclusive.
MmioPtr.address
public fn address(borrow this) -> usizeThe address of the registers, as given to at.
struct NumberParsing
public struct NumberParsingParsing integers and floats from bytes: static functions; the struct has no fields and is never made.
NumberParsing.parseU8
public fn parseU8(s: Slice<u8>) -> u8?Decimal text as a u8.
NumberParsing.parseU8Radix
public fn parseU8Radix(s: Slice<u8>, radix: u32) -> u8?Text in radix (2 to 36; null otherwise) as a u8.
NumberParsing.parseU16
public fn parseU16(s: Slice<u8>) -> u16?Decimal text as a u16.
NumberParsing.parseU16Radix
public fn parseU16Radix(s: Slice<u8>, radix: u32) -> u16?Text in radix (2 to 36; null otherwise) as a u16.
NumberParsing.parseU32
public fn parseU32(s: Slice<u8>) -> u32?Decimal text as a u32.
NumberParsing.parseU32Radix
public fn parseU32Radix(s: Slice<u8>, radix: u32) -> u32?Text in radix (2 to 36; null otherwise) as a u32.
NumberParsing.parseU64
public fn parseU64(s: Slice<u8>) -> u64?Decimal text as a u64.
NumberParsing.parseU64Radix
public fn parseU64Radix(s: Slice<u8>, radix: u32) -> u64?Text in radix (2 to 36; null otherwise) as a u64.
NumberParsing.parseUsize
public fn parseUsize(s: Slice<u8>) -> usize?Decimal text as a usize.
NumberParsing.parseUsizeRadix
public fn parseUsizeRadix(s: Slice<u8>, radix: u32) -> usize?Text in radix (2 to 36; null otherwise) as a usize.
NumberParsing.parseI8
public fn parseI8(s: Slice<u8>) -> i8?Decimal text as an i8.
NumberParsing.parseI8Radix
public fn parseI8Radix(s: Slice<u8>, radix: u32) -> i8?Text in radix (2 to 36; null otherwise) as an i8.
NumberParsing.parseI16
public fn parseI16(s: Slice<u8>) -> i16?Decimal text as an i16.
NumberParsing.parseI16Radix
public fn parseI16Radix(s: Slice<u8>, radix: u32) -> i16?Text in radix (2 to 36; null otherwise) as an i16.
NumberParsing.parseI32
public fn parseI32(s: Slice<u8>) -> i32?Decimal text as an i32.
NumberParsing.parseI32Radix
public fn parseI32Radix(s: Slice<u8>, radix: u32) -> i32?Text in radix (2 to 36; null otherwise) as an i32.
NumberParsing.parseI64
public fn parseI64(s: Slice<u8>) -> i64?Decimal text as an i64.
NumberParsing.parseI64Radix
public fn parseI64Radix(s: Slice<u8>, radix: u32) -> i64?Text in radix (2 to 36; null otherwise) as an i64.
NumberParsing.parseIsize
public fn parseIsize(s: Slice<u8>) -> isize?Decimal text as an isize.
NumberParsing.parseIsizeRadix
public fn parseIsizeRadix(s: Slice<u8>, radix: u32) -> isize?Text in radix (2 to 36; null otherwise) as an isize.
NumberParsing.parseF64
public fn parseF64(s: Slice<u8>) -> f64?Text as an f64, correctly rounded, or null. [+-]digits[.digits][(e|E)[+-]digits] with a digit on at least one side of the point, or inf, infinity or nan in any case, with an optional sign. Too large is ±infinity.
NumberParsing.parseF32
public fn parseF32(s: Slice<u8>) -> f32?Text as an f32, correctly rounded (once: not through an f64), or null; the grammar of parseF64.
struct ResultMethods
public struct ResultMethods<T, E>Result<T, E>'s methods.
ResultMethods.isOk
public fn isOk(r: borrow Result<T, E>) -> boolWhether r is Ok.
ResultMethods.isErr
public fn isErr(r: borrow Result<T, E>) -> boolWhether r is Err.
ResultMethods.ok
public fn ok(r: Result<T, E>) -> T?The Ok value, or null; an Err value is destroyed.
ResultMethods.err
public fn err(r: Result<T, E>) -> E?The Err value, or null; an Ok value is destroyed.
struct OptionalResults
public struct OptionalResults<T, E>o.okOr(e): an optional as a Result.
OptionalResults.okOr
public fn okOr(o: T?, e: E) -> Result<T, E>Ok with the value, or Err(e) for null; e is destroyed when there is a value.
struct SliceHalves
public struct SliceHalves<region r, T> {
public left: Slice<r, T>;
public right: Slice<r, T>;
}The two parts of a slice that splitAt divides (type-system.md §16.5): the elements before the split, and from it on.
struct SliceHalvesMut
public struct SliceHalvesMut<region r, T> {
public left: SliceMut<r, T>;
public right: SliceMut<r, T>;
}The two parts of a mutable slice that splitAtMut divides: disjoint, so both may be written at once.
struct SliceSplitting
public struct SliceSplitting<region r, T>Splitting a slice in two (type-system.md §16.5): s.splitAt(mid) is SliceSplitting<T>.splitAt(s, mid). The struct's region ties the halves to the slice they come from; it has no fields and is never made.
SliceSplitting.splitAt
public fn splitAt(s: Slice<r, T>, mid: usize) -> SliceHalves<r, T>The elements before mid, and from mid on; panics if mid is past the end.
SliceSplitting.splitAtMut
public fn splitAtMut(s: SliceMut<r, T>, mid: usize) -> SliceHalvesMut<r, T>As splitAt, for a mutable slice: two mutable slices that do not overlap. Safety: slicing s[mid..] checks mid against the length (it panics past the end), so [0, mid) and [mid, length) are inside s and disjoint, and each is lent for as long as s is.
struct SliceAlgorithms
public struct SliceAlgorithms<T>The algorithms over a slice of T, as static functions: the struct has no fields and is never made.
SliceAlgorithms.sortBy
@effectsOf(cmp)
public fn sortBy(s: SliceMut<T>, cmp: borrow mut fn(borrow T, borrow T) -> i32)Orders s so that cmp of each element and the next is at most zero, for a consistent cmp. Not stable. An introsort (ADR 0057): quicksort with a median-of-three pivot and a partition without a branch on cmp's result, the elements equal to an earlier pivot set aside at once, insertion sort for short runs, and heapsort past a depth of 2·log₂ n, so O(n log n) calls of cmp in the worst case. A slice that is one ascending run is left as it is, and one strictly descending run is reversed. Allocates nothing; the shorter side is sorted first, so at most 64 ranges wait. An inconsistent cmp leaves some permutation of s.
SliceAlgorithms.forEach
@effectsOf(visit)
public fn forEach(s: Slice<T>, visit: borrow mut fn(borrow T))Calls visit on each element, in index order.
SliceAlgorithms.any
@effectsOf(test)
public fn any(s: Slice<T>, test: borrow mut fn(borrow T) -> bool) -> boolDoes test return true for some element? Stops at the first that does.
SliceAlgorithms.all
@effectsOf(test)
public fn all(s: Slice<T>, test: borrow mut fn(borrow T) -> bool) -> boolDoes test return true for every element? Stops at the first that does not.
SliceAlgorithms.retain
@effectsOf(keep)
public fn retain(s: SliceMut<T>, keep: borrow mut fn(borrow T) -> bool) -> usizeMoves the elements for which keep returns true to the front, in order, calling it once on each element in index order; returns how many there are. v.retain(keep) then truncates the vector to that length.
struct VectorEditing
public struct VectorEditing<T>v.insert(at, x), v.remove(at) and v.swapRemove(at) (ADR 0075 §2.12). The index is checked at the call, so a panic names the program's line: at <= length for insert, at < length for the others. The elements move by swap, so they may be of any type. A vector's allocator is SystemHeap or FailingAllocator (type-system.md §23.1); the …Failing functions are the latter's.
VectorEditing.insert
public fn insert(v: borrow mut Vector<T>, at: usize, x: T) -> Result<void, AllocError>Puts x at at, moving the elements from at on one place up. O(length - at). If growing fails, v is unchanged and x is destroyed.
VectorEditing.remove
public fn remove(v: borrow mut Vector<T>, at: usize) -> TTakes the element at at out, moving the later elements one place down. O(length - at).
VectorEditing.swapRemove
public fn swapRemove(v: borrow mut Vector<T>, at: usize) -> TTakes the element at at out and puts the last element in its place. O(1); the order is not kept.
VectorEditing.insertFailing
public fn insertFailing(v: borrow mut Vector<T, FailingAllocator>, at: usize, x: T) -> Result<void, AllocError>insert for a vector of FailingAllocator.
VectorEditing.removeFailing
public fn removeFailing(v: borrow mut Vector<T, FailingAllocator>, at: usize) -> Tremove for a vector of FailingAllocator.
VectorEditing.swapRemoveFailing
public fn swapRemoveFailing(v: borrow mut Vector<T, FailingAllocator>, at: usize) -> TswapRemove for a vector of FailingAllocator.
struct TextHalves
public struct TextHalves<region r> {
public left: StringView<r>;
public right: StringView<r>;
}The parts of a text before and after a separator: what s.splitOnce(sep) finds.
struct ByteHalves
public struct ByteHalves<region r> {
public left: Slice<r, u8>;
public right: Slice<r, u8>;
}The parts of bytes before and after a separator: what s.splitOnce(sep) finds on a Slice<u8>.
struct TextSplit
public struct TextSplit<region r>The pieces of a text between separators, in order: s.split(sep). next() gives each piece, then null. "a,,b" split by "," is "a", "", "b"; an empty text is one empty piece; an empty separator gives the text whole.
Implements Iterator<StringView<r>>.
struct ByteSplit
public struct ByteSplit<region r>The pieces of bytes between separators, in order: s.split(sep) on a Slice<u8>, as TextSplit.
Implements Iterator<Slice<r, u8>>.
struct TextSearch
public struct TextSearch<region r>The methods of a StringView that search it (ADR 0071 §2.4), as static functions: the struct is never made.
TextSearch.indexOf
public fn indexOf(s: StringView<r>, needle: StringView) -> usize?TextSearch.lastIndexOf
public fn lastIndexOf(s: StringView<r>, needle: StringView) -> usize?TextSearch.indexOfByte
public fn indexOfByte(s: StringView<r>, b: u8) -> usize?TextSearch.contains
public fn contains(s: StringView<r>, needle: StringView) -> boolTextSearch.startsWith
public fn startsWith(s: StringView<r>, prefix: StringView) -> boolTextSearch.endsWith
public fn endsWith(s: StringView<r>, suffix: StringView) -> boolTextSearch.equalsIgnoreAsciiCase
public fn equalsIgnoreAsciiCase(s: StringView<r>, other: StringView) -> boolTextSearch.trim
public fn trim(s: StringView<r>) -> StringView<r>TextSearch.trimStart
public fn trimStart(s: StringView<r>) -> StringView<r>TextSearch.trimEnd
public fn trimEnd(s: StringView<r>) -> StringView<r>TextSearch.splitOnce
public fn splitOnce(s: StringView<r>, separator: StringView) -> TextHalves<r>?The text before the first separator and after it, or null if it does not occur. An empty separator is found at the start.
TextSearch.split
public fn split(s: StringView<r>, separator: StringView<r>) -> TextSplit<r>struct ByteSearch
public struct ByteSearch<region r>The methods of a Slice<u8> that search it (ADR 0071 §2.4), as TextSearch's.
ByteSearch.indexOf
public fn indexOf(s: Slice<r, u8>, needle: Slice<u8>) -> usize?ByteSearch.lastIndexOf
public fn lastIndexOf(s: Slice<r, u8>, needle: Slice<u8>) -> usize?ByteSearch.indexOfByte
public fn indexOfByte(s: Slice<r, u8>, b: u8) -> usize?ByteSearch.contains
public fn contains(s: Slice<r, u8>, needle: Slice<u8>) -> boolByteSearch.startsWith
public fn startsWith(s: Slice<r, u8>, prefix: Slice<u8>) -> boolByteSearch.endsWith
public fn endsWith(s: Slice<r, u8>, suffix: Slice<u8>) -> boolByteSearch.equalsIgnoreAsciiCase
public fn equalsIgnoreAsciiCase(s: Slice<r, u8>, other: Slice<u8>) -> boolByteSearch.trim
public fn trim(s: Slice<r, u8>) -> Slice<r, u8>ByteSearch.trimStart
public fn trimStart(s: Slice<r, u8>) -> Slice<r, u8>ByteSearch.trimEnd
public fn trimEnd(s: Slice<r, u8>) -> Slice<r, u8>ByteSearch.splitOnce
public fn splitOnce(s: Slice<r, u8>, separator: Slice<u8>) -> ByteHalves<r>?ByteSearch.split
public fn split(s: Slice<r, u8>, separator: Slice<r, u8>) -> ByteSplit<r>