solar-data-structures 0.2.0

Common data structures and utilities for the Solar compiler
Documentation
#![doc = include_str!("../README.md")]
#![doc(
    html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/solar/main/assets/logo.png",
    html_favicon_url = "https://raw.githubusercontent.com/paradigmxyz/solar/main/assets/favicon.ico"
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(feature = "nightly", feature(core_intrinsics))]
#![cfg_attr(feature = "nightly", feature(never_type))]
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
#![cfg_attr(feature = "nightly", feature(extern_types))]
#![cfg_attr(feature = "nightly", allow(internal_features))]

pub mod cycle;
pub mod fmt;
pub mod hint;
pub mod index;
pub mod map;
pub mod sync;
pub mod trustme;

pub mod bit_set;

mod bump_ext;
pub use bump_ext::BumpExt;

mod collect;
pub use collect::CollectAndApply;

mod never;
pub use never::Never;

mod drop_guard;
pub use drop_guard::{DropGuard, defer};

mod interned;
pub use interned::Interned;

mod thin_slice;
pub use thin_slice::{RawThinSlice, ThinSlice};

#[doc(no_inline)]
pub use smallvec;

/// Pluralize a word based on a count.
#[macro_export]
#[rustfmt::skip]
macro_rules! pluralize {
    // Pluralize based on count (e.g., apples)
    ($x:expr) => {
        if $x == 1 { "" } else { "s" }
    };
    ("has", $x:expr) => {
        if $x == 1 { "has" } else { "have" }
    };
    ("is", $x:expr) => {
        if $x == 1 { "is" } else { "are" }
    };
    ("was", $x:expr) => {
        if $x == 1 { "was" } else { "were" }
    };
    ("this", $x:expr) => {
        if $x == 1 { "this" } else { "these" }
    };
}

/// This calls the passed function while ensuring it won't be inlined into the caller.
#[inline(never)]
#[cold]
pub fn outline<R>(f: impl FnOnce() -> R) -> R {
    f()
}