use std::rc::Rc;
#[derive(Debug, Clone)]
pub enum Ir {
Text(Rc<str>),
Concat(Rc<[Ir]>),
Line,
SoftLine,
HardLine,
BlankLine,
Indent(Rc<Ir>),
Group(Rc<Ir>),
IfBreak(Rc<str>, Rc<str>),
}
impl Ir {
pub fn text(s: impl Into<Rc<str>>) -> Ir {
Ir::Text(s.into())
}
pub fn concat(items: impl IntoIterator<Item = Ir>) -> Ir {
Ir::Concat(items.into_iter().collect())
}
pub fn group(inner: Ir) -> Ir {
Ir::Group(Rc::new(inner))
}
pub fn indent(inner: Ir) -> Ir {
Ir::Indent(Rc::new(inner))
}
pub fn if_break(broken: impl Into<Rc<str>>, flat: impl Into<Rc<str>>) -> Ir {
Ir::IfBreak(broken.into(), flat.into())
}
}