use super::Node;
use gc::{Finalize, Trace};
use std::fmt;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)]
pub struct Spread {
val: Box<Node>,
}
impl Spread {
pub fn val(&self) -> &Node {
&self.val
}
pub fn new<V>(val: V) -> Self
where
V: Into<Node>,
{
Self {
val: Box::new(val.into()),
}
}
}
impl fmt::Display for Spread {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "...{}", self.val())
}
}
impl From<Spread> for Node {
fn from(spread: Spread) -> Node {
Self::Spread(spread)
}
}