Provides a compact, interned string type for efficient storage and lookup.
// Source: https://github.com/typst/typst | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
use std::borrow::Borrow;
use std::cmp::Ordering;
use std::fmt::{self, Debug, Display, Formatter};
use std::hash::{Hash, Hasher};
use std::num::NonZeroU64;
use std::ops::Deref;
use std::sync::{LazyLock, RwLock};
use rustc_hash::FxHashMap;
/// Marks a number as a bitcode encoded [`PicoStr`].
const MARKER: u64 = 1 << 63;
/// The global runtime string interner.
static INTERNER: LazyLock<RwLock<Interner>> = LazyLock::new(|| {
RwLock::new(Interner { seen: FxHashMap::default(), strings: Vec::new() })
});
/// A string interner.
struct Interner {
seen: FxHashMap<&'static str, PicoStr>,
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key