#![allow(unused)]
use core::cell::UnsafeCell;
use core::fmt;
use core::mem::{align_of, size_of, size_of_val};
use core::ops::{Deref, DerefMut};
mod spin;
pub use spin::{Spin, SpinGuard};
mod ticket;
pub use ticket::{Ticket, TicketGuard};
mod once;
pub use once::{AlreadyInitialized, Once};
#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(transparent)]
pub struct InlineStr<const N: usize>(pub [u8; N]);
impl<const N: usize> InlineStr<N> {
pub fn as_str(&self) -> &str {
core::str::from_utf8(&self.0).unwrap_or_default()
}
}
impl<const N: usize> fmt::Debug for InlineStr<N> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.as_str())
}
}
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct RefStr(pub *const i8);
impl RefStr {
pub fn as_str(&self) -> &str {
if !self.0.is_null() {
unsafe {
core::ffi::CStr::from_ptr(self.0)
.to_str()
.unwrap_or_default()
}
} else {
""
}
}
}
impl fmt::Debug for RefStr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.as_str())
}
}