use std::fmt::{self, Debug, Display};
pub trait Literal: 'static {
const LITERAL: &'static str;
}
#[derive(Debug)]
pub struct Blank(#[allow(unused)] [()]);
impl Literal for Blank {
const LITERAL: &'static str = "";
}
pub trait Context: Literal {
type Repr: Display + Debug + Send + Sync + 'static;
fn new_context() -> Self::Repr;
}
impl<L> Context for L
where
L: Literal,
{
type Repr = &'static str;
fn new_context() -> Self::Repr {
L::LITERAL
}
}
impl Context for Blank {
type Repr = Unit;
fn new_context() -> Self::Repr {
Unit
}
}
#[derive(Debug)]
pub struct Unit;
impl Display for Unit {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
Ok(())
}
}