use crate::ns::*; use serde::{Serialize, Deserialize}; use std::rc::Rc; #[derive(Clone, Serialize, Deserialize)] pub struct ObjectInitializer { pub location: Location, pub fields: Vec>, pub type_annotation: Option>, } #[derive(Clone, Serialize, Deserialize)] pub enum InitializerField { Field { name: (FieldName, Location), /// Non-null operator used for destructuring. non_null: bool, value: Option>, }, Rest((Rc, Location)), } impl InitializerField { pub fn location(&self) -> Location { match self { Self::Field { ref name, ref value, .. } => { value.clone().map_or(name.1.clone(), |v| name.1.combine_with(v.location())) }, Self::Rest((_, ref l)) => l.clone(), } } } #[derive(Clone, Serialize, Deserialize)] pub enum FieldName { Identifier(String), Brackets(Rc), StringLiteral(Rc), NumericLiteral(Rc), }