pub mod border;
pub mod cell;
pub mod engine;
pub mod kinds;
pub mod rect;
pub mod text;
pub use rect::Rect;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum LayoutAllocationSite {
TempVec,
FixedMetadata,
WrappedText,
}
#[cfg(test)]
thread_local! {
static REJECT_LAYOUT_ALLOCATION: std::cell::Cell<Option<LayoutAllocationSite>> =
const { std::cell::Cell::new(None) };
}
#[cfg(test)]
pub(crate) struct LayoutRejectionGuard;
#[cfg(test)]
impl LayoutRejectionGuard {
pub(crate) fn at(site: LayoutAllocationSite) -> Self {
REJECT_LAYOUT_ALLOCATION.with(|rejected| rejected.set(Some(site)));
Self
}
}
#[cfg(test)]
impl Drop for LayoutRejectionGuard {
fn drop(&mut self) {
REJECT_LAYOUT_ALLOCATION.with(|rejected| rejected.set(None));
}
}
#[cfg(test)]
pub(crate) fn reject_layout_allocation(site: LayoutAllocationSite) -> bool {
REJECT_LAYOUT_ALLOCATION.with(|rejected| rejected.get() == Some(site))
}
#[cfg(not(test))]
pub(crate) fn reject_layout_allocation(_site: LayoutAllocationSite) -> bool {
false
}