#![allow(unused_imports)]
#[cfg(not(feature = "std"))]
pub use alloc::{
borrow::ToOwned,
boxed::Box,
format,
string::{String, ToString},
vec,
vec::Vec,
};
#[cfg(feature = "std")]
pub use std::{
borrow::ToOwned,
boxed::Box,
format,
string::{String, ToString},
vec,
vec::Vec,
};
pub use hashbrown::HashMap;
#[cfg(not(feature = "std"))]
pub use spin::{Lazy, Mutex, Once, RwLock};
#[cfg(feature = "std")]
pub use std::sync::{Mutex, OnceLock, RwLock};
#[cfg(feature = "std")]
pub use std::sync::LazyLock as Lazy;
pub use core::sync::atomic::{AtomicUsize, Ordering};
#[cfg(target_has_atomic = "64")]
pub use core::sync::atomic::AtomicU64;
#[cfg(not(feature = "std"))]
pub type OnceLock<T> = spin::Once<T>;
#[cfg(not(feature = "std"))]
pub trait OnceLockExt<T> {
fn get_or_init<F>(&self, f: F) -> &T
where
F: FnOnce() -> T;
}
#[cfg(not(feature = "std"))]
impl<T> OnceLockExt<T> for spin::Once<T> {
fn get_or_init<F>(&self, f: F) -> &T
where
F: FnOnce() -> T,
{
self.call_once(f)
}
}
pub use core::f64::consts::PI;
#[cfg(feature = "std")]
#[inline]
pub fn rwlock_read<T>(lock: &std::sync::RwLock<T>) -> std::sync::RwLockReadGuard<'_, T> {
lock.read().expect("RwLock poisoned")
}
#[cfg(feature = "std")]
#[inline]
pub fn rwlock_write<T>(lock: &std::sync::RwLock<T>) -> std::sync::RwLockWriteGuard<'_, T> {
lock.write().expect("RwLock poisoned")
}
#[cfg(not(feature = "std"))]
#[inline]
pub fn rwlock_read<T>(lock: &spin::RwLock<T>) -> spin::RwLockReadGuard<'_, T> {
lock.read()
}
#[cfg(not(feature = "std"))]
#[inline]
pub fn rwlock_write<T>(lock: &spin::RwLock<T>) -> spin::RwLockWriteGuard<'_, T> {
lock.write()
}