liquid_core/model/value/
display.rs1use std::fmt;
2
3#[allow(missing_debug_implementations)]
5pub enum DisplayCow<'a> {
6 Owned(Box<dyn fmt::Display + 'a>),
8 Borrowed(&'a dyn fmt::Display),
10}
11
12impl DisplayCow<'_> {
13 fn as_ref(&self) -> &dyn fmt::Display {
14 match self {
15 DisplayCow::Owned(o) => o.as_ref(),
16 DisplayCow::Borrowed(b) => b,
17 }
18 }
19}
20
21impl fmt::Display for DisplayCow<'_> {
22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23 self.as_ref().fmt(f)
24 }
25}
26
27pub(crate) struct StrDisplay {
28 pub(crate) s: &'static str,
29}
30
31impl fmt::Display for StrDisplay {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 write!(f, "{}", self.s)
34 }
35}