logos.lang.slice

Module lang · package logos-lang

Types

structChunks

struct Chunks

Iterator over non-overlapping chunks of a slice, created by slice_chunks.

Implements: Iterator

Fields

data: *const T

Base pointer of the underlying slice.

len: i64

Total element count of the underlying slice.

pos: i64

Current element offset; advances by the yielded chunk’s length.

step: i64

Chunk size in elements.

structSplitPair

struct SplitPair

Raw (ptr, len) halves of a slice split, as produced by slice_split_at.

Fields

left_len: i64

Element count of the left half.

left_ptr: *const T

Pointer to the first element of the left half.

right_len: i64

Element count of the right half.

right_ptr: *const T

Pointer to the first element of the right half.

structWindows

struct Windows

Iterator over overlapping size-element windows of a slice, created by slice_windows.

Implements: Iterator

Fields

data: *const T

Base pointer of the underlying slice.

len: i64

Total element count of the underlying slice.

pos: i64

Current window start offset; advances by 1 per step.

size: i64

Window size in elements.

Functions

fnslice_chunks

fn slice_chunks(s: &[T], size: i64) -> Chunks<T>

Returns an iterator over non-overlapping size-element chunks of s. The last chunk is shorter when s.len() % size != 0; empty input yields no chunks. size must be positive: non-positive size is unchecked, and size == 0 makes next yield empty chunks forever on a non-empty slice.

fnslice_from_raw

fn slice_from_raw(ptr: *const T, len: i64) -> &[T]

Constructs an &[T] fat pointer from a raw pointer and element count. Compiler intrinsic (sema intercepts the call); mirrors str_from_raw in lang/str. ptr must be valid for reads of len elements for as long as the result is used.

fnslice_get_range

fn slice_get_range(s: &[T], lo: i64, hi: i64) -> &[T]

Returns the sub-slice s[lo..hi] (backs the range-indexing desugar). Bounds are clamped to [0, len]: open range forms pass lo=0 / hi=i64::MAX and the clamp resolves them against the true length. Inclusive ..=hi passes hi+1. Empty when hi <= lo after clamping.

fnslice_sort

fn slice_sort(base: *mut T, n: i64) -> void

Sorts the n elements at base in place, ascending (stable insertion sort, O(n^2)). base must be valid for reads and writes of n elements. Intended for small n.

fnslice_split_at

fn slice_split_at(s: &[T], mid: i64) -> SplitPair<T>

Splits s at mid, returning raw (ptr, len) pairs for both halves. mid is clamped to s.len() (no panic, unlike Rust). Rebuild typed &[T] halves with slice_from_raw.

fnslice_windows

fn slice_windows(s: &[T], size: i64) -> Windows<T>

Returns an iterator over overlapping size-element windows of s, advancing by 1. Yields nothing if size <= 0 or size > s.len() (unlike Rust, size == 0 does not panic).