Skip to main content

alchemy_lifecycle/rsx/
virtual_text.rs

1//! Implements `RSX::VirtualText`, which holds data pertaining to <Text>, primarily.
2
3use std::fmt::{Display, Debug};
4
5/// Currently a wrapper for `String`, but could be something else down the road. Frees
6/// us from needing to change the public API later.
7#[derive(Clone)]
8pub struct VirtualText(pub String);
9
10impl VirtualText {
11    /// Given a `String`, returns a `VirtualText` node.
12    pub fn new(s: String) -> VirtualText {
13        VirtualText(s)
14    }
15}
16
17impl Display for VirtualText {
18    /// Formatting for `VirtualText` display.
19    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
20        write!(f, "{}", self.0)
21    }
22}
23
24impl Debug for VirtualText {
25    /// Formatting for `VirtualText` debugging.
26    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
27        write!(f, "VirtualText({})", self.0)
28    }
29}