Skip to main content

solar_data_structures/
lib.rs

1#![doc = include_str!("../README.md")]
2#![doc(
3    html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/solar/main/assets/logo.png",
4    html_favicon_url = "https://raw.githubusercontent.com/paradigmxyz/solar/main/assets/favicon.ico"
5)]
6#![cfg_attr(docsrs, feature(doc_cfg))]
7#![cfg_attr(feature = "nightly", feature(core_intrinsics))]
8#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
9#![cfg_attr(feature = "nightly", feature(extern_types))]
10#![cfg_attr(feature = "nightly", feature(never_type))]
11#![cfg_attr(feature = "nightly", allow(internal_features, stable_features))]
12
13pub mod fmt;
14pub mod graph;
15pub mod hint;
16pub mod index;
17pub mod map;
18pub mod sync;
19pub mod trustme;
20
21pub mod bit_set;
22
23mod bump_ext;
24pub use bump_ext::BumpExt;
25
26mod collect;
27pub use collect::CollectAndApply;
28
29mod never;
30pub use never::Never;
31
32mod drop_guard;
33pub use drop_guard::{DropGuard, defer};
34
35#[doc(hidden)]
36mod drop_arena;
37#[doc(hidden)]
38pub use drop_arena::DropArena;
39
40mod interned;
41pub use interned::Interned;
42
43mod thin_slice;
44pub use thin_slice::{RawThinSlice, ThinSlice};
45
46#[doc(no_inline)]
47pub use smallvec;
48
49/// Pluralize a word based on a count.
50#[macro_export]
51#[rustfmt::skip]
52macro_rules! pluralize {
53    // Pluralize based on count (e.g., apples)
54    ($x:expr) => {
55        if $x == 1 { "" } else { "s" }
56    };
57    ("has", $x:expr) => {
58        if $x == 1 { "has" } else { "have" }
59    };
60    ("is", $x:expr) => {
61        if $x == 1 { "is" } else { "are" }
62    };
63    ("was", $x:expr) => {
64        if $x == 1 { "was" } else { "were" }
65    };
66    ("this", $x:expr) => {
67        if $x == 1 { "this" } else { "these" }
68    };
69}
70
71/// This calls the passed function while ensuring it won't be inlined into the caller.
72#[inline(never)]
73#[cold]
74pub fn outline<R>(f: impl FnOnce() -> R) -> R {
75    f()
76}