use crate::syntax::ast::node::Node;
use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")]
use serde::{Deserialize, Serialize};
#[cfg(test)]
mod tests;
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "deser", serde(transparent))]
#[derive(Clone, Debug, 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 ToInternedString for Spread {
fn to_interned_string(&self, interner: &Interner) -> String {
format!("...{}", self.val().to_interned_string(interner))
}
}
impl From<Spread> for Node {
fn from(spread: Spread) -> Self {
Self::Spread(spread)
}
}