1use arcstr::Substr;
5
6#[derive(Debug)]
8pub enum PrintOutput {
9 Empty,
11
12 Input(Substr),
14
15 String(String),
17}
18
19impl PrintOutput {
20 pub fn make_string(&mut self) -> &mut String {
22 match self {
23 Self::Empty => *self = Self::String(String::new()),
24 Self::Input(s) => {
25 let s = s.as_str().to_owned();
26 *self = Self::String(s);
27 },
28 Self::String(_) => (),
29 }
30
31 match self {
32 Self::String(s) => s,
33 _ => unreachable!()
34 }
35 }
36
37 #[must_use]
39 pub fn as_str(&self) -> &str {
40 match self {
41 Self::Empty => "",
42 Self::Input(s) => s,
43 Self::String(s) => s,
44 }
45 }
46}