use std::fmt;
pub const DEFAULT_DEPTH_LIMIT: usize = 128;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Cfg<const WITH_IDENTS: bool> {
depth_limit: usize,
}
impl<const WITH_IDENTS: bool> Cfg<WITH_IDENTS> {
pub const DEFAULT_DEPTH_LIMIT: usize = DEFAULT_DEPTH_LIMIT;
pub const fn new() -> Self {
Self { depth_limit: DEFAULT_DEPTH_LIMIT }
}
pub const fn with_idents(&self) -> bool {
WITH_IDENTS
}
pub const fn with_depth_limit(self, depth_limit: usize) -> Self {
Self { depth_limit }
}
pub const fn depth_limit(&self) -> usize {
self.depth_limit
}
}
impl<const WITH_IDENTS: bool> Default for Cfg<WITH_IDENTS> {
fn default() -> Self {
Self::new()
}
}
impl<const WITH_IDENTS: bool> fmt::Debug for Cfg<WITH_IDENTS> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Cfg").field("with_idents", &WITH_IDENTS).field("depth_limit", &self.depth_limit).finish()
}
}
pub type Full = Cfg<true>;
pub type Slim = Cfg<false>;