Skip to main content

bast3st_eval/
log_pfx.rs

1#[cfg(not(feature = "no-log-pfx"))]
2#[derive(derive_more::Debug, derive_more::Display, Clone, PartialEq, Eq, PartialOrd, Ord)]
3pub struct LogPfx(Box<str>);
4
5#[cfg(not(feature = "no-log-pfx"))]
6impl LogPfx {
7    pub fn new(t: impl Into<Box<str>>) -> Self {
8        Self(format!("{:?}", t.into()).into())
9    }
10    pub fn join(&self, text: impl std::fmt::Debug) -> LogPfx {
11        LogPfx(format!("{}/{:?}", self.0, text).into())
12    }
13}
14#[cfg(not(feature = "no-log-pfx"))]
15impl From<&str> for LogPfx {
16    fn from(value: &str) -> Self {
17        Self(format!("{value:?}").into())
18    }
19}
20
21#[cfg(not(feature = "no-log-pfx"))]
22impl From<String> for LogPfx {
23    fn from(value: String) -> Self {
24        Self(value.into())
25    }
26}
27
28#[cfg(feature = "no-log-pfx")]
29#[derive(derive_more::Debug, derive_more::Display, Clone, PartialEq, Eq, PartialOrd, Ord)]
30#[display("")]
31pub struct LogPfx(());
32
33#[cfg(feature = "no-log-pfx")]
34impl LogPfx {
35    pub fn new(t: impl Into<Box<str>>) -> Self {
36        Self(())
37    }
38    pub fn join(&self, text: impl std::fmt::Debug) -> LogPfx {
39        LogPfx(())
40    }
41}
42#[cfg(feature = "no-log-pfx")]
43impl From<&str> for LogPfx {
44    fn from(value: &str) -> Self {
45        Self(())
46    }
47}
48#[cfg(feature = "no-log-pfx")]
49impl From<String> for LogPfx {
50    fn from(value: String) -> Self {
51        Self(())
52    }
53}