Expand description
A high-performance, globally-interned string library for the Mago ecosystem.
This crate provides Atom, a canonical string type that guarantees any given
string is stored in memory only once. It acts as a wrapper for the ustr crate and adds
highly-optimized constructors for common string manipulations like lowercasing,
concatenation, and number formatting.
The key feature is the ability to perform these operations without heap allocations for common cases by using stack-allocated buffers, making this crate ideal for performance-critical code.
§Usage
use mago_atom::*;
// Create an Atom. This is a cheap lookup in a global cache.
let s1 = atom("Hello");
// Use an optimized, zero-heap-allocation constructor.
let s2 = ascii_lowercase_atom("Hello");
assert_eq!(s2.as_str(), "hello");
// Use the specialized, high-performance map.
let mut map = AtomMap::default();
map.insert(s1, 123);Macros§
- concat_
atom - A macro to concatenate between 2 and 12 string slices into a single
Atom.
Structs§
- Atom
- A handle representing a string in the global string cache.
Functions§
- ascii_
lowercase_ atom - Creates an
Atomfrom a lowercased version of a string slice. - ascii_
lowercase_ constant_ name_ atom - Creates an
Atomfrom a constant name, lowercasing only the namespace part. - atom
- Create a new
Ustrfrom the givenstr. - concat_
atom2 - Creates an
Atomas a result of concatenating 2 string slices. - concat_
atom3 - Creates an
Atomas a result of concatenating 3 string slices. - concat_
atom4 - Creates an
Atomas a result of concatenating 4 string slices. - concat_
atom5 - Creates an
Atomas a result of concatenating 5 string slices. - concat_
atom6 - Creates an
Atomas a result of concatenating 6 string slices. - concat_
atom7 - Creates an
Atomas a result of concatenating 7 string slices. - concat_
atom8 - Creates an
Atomas a result of concatenating 8 string slices. - concat_
atom9 - Creates an
Atomas a result of concatenating 9 string slices. - concat_
atom10 - Creates an
Atomas a result of concatenating 10 string slices. - concat_
atom11 - Creates an
Atomas a result of concatenating 11 string slices. - concat_
atom12 - Creates an
Atomas a result of concatenating 12 string slices. - empty_
atom - Returns the canonical
Atomfor an empty string. - f32_
atom - Creates an
Atomfrom af32value with zero heap allocations. - f64_
atom - Creates an
Atomfrom af64value with zero heap allocations. - i8_atom
- Creates an
Atomfrom ai8value with zero heap allocations. - i16_
atom - Creates an
Atomfrom ai16value with zero heap allocations. - i32_
atom - Creates an
Atomfrom ai32value with zero heap allocations. - i64_
atom - Creates an
Atomfrom ai64value with zero heap allocations. - i128_
atom - Creates an
Atomfrom ai128value with zero heap allocations. - isize_
atom - Creates an
Atomfrom aisizevalue with zero heap allocations. - starts_
with_ ignore_ case - Checks if
haystackstarts withprefix, ignoring ASCII case. - u8_atom
- Creates an
Atomfrom au8value with zero heap allocations. - u16_
atom - Creates an
Atomfrom au16value with zero heap allocations. - u32_
atom - Creates an
Atomfrom au32value with zero heap allocations. - u64_
atom - Creates an
Atomfrom au64value with zero heap allocations. - u128_
atom - Creates an
Atomfrom au128value with zero heap allocations. - usize_
atom - Creates an
Atomfrom ausizevalue with zero heap allocations.