-
Notifications
You must be signed in to change notification settings - Fork 7
Project Standard Library
This crate is an extension of Rust's standard library. It consists of self-contained functionality that are used throughout Sourceror.
Each module in this crate is listed below.
SearchableVec is like std::vec::Vec, but will not allow duplicate elements. It has an insert(&mut self, value: T) -> usize
method, which inserts the value if it does not already exist in the vector. It returns the index into the vector of the element insert (or the existing element, if exists). It is implemented using additional HashMap. It is used in various situations where we want deduplication, such as in Wasmgen for the type section of a WebAssembly module.
This module defines the "severity level" enum and "source location" struct that is used for reporting compilation errors. It also defines a Logger trait that uses the severity level and source location.
Small helper to convert (Vec<T1>, Vec<T2>)
into (Box<[T1]>, Box<[T2]>)
. This is used with unzip()
, because you can't directly unzip into (Box<[T1]>, Box<[T2]>)
.
This is a collection of useful iterators.
Works like std::iter::once_with
, which was unstable when projstd::iter::once_with
was implemented. This is currently not used in Sourceror.
This is an iterator that coalesces adjacent elements that are equal, and returns a iterator of pair (element, count)
. For example, it converts [3,3,5,7,7,7,6,6,7,7]
into [(3,2),(5,1),(7,3),(6,2),(7,2)]
. This is used in Wasmgen for serializing the locals of a WebAssembly binary, because the coalesced syntax is required as part of the WebAssembly binary format.
This is an iterator that is like scan()
, but takes in a mutable reference of the state instead of a value. This allows the caller to inspect the final value of the state.