use std::any::{Any, TypeId}; use std::collections::HashMap; use std::fmt::{self, Debug, Formatter}; use std::hash::{Hash, Hasher}; use std::{mem, ptr}; use comemo::Tracked; use ecow::{EcoString, EcoVec, eco_vec}; use smallvec::SmallVec; use typst_syntax::Span; use typst_utils::LazyHash; use crate::diag::{SourceResult, Trace, Tracepoint}; use crate::engine::Engine; use crate::foundations::{ Content, Context, Element, Field, Func, NativeElement, OneOrMultiple, Packed, RefableProperty, Repr, Selector, SettableProperty, Target, cast, ty, }; use crate::text::{FontFamily, FontList, TextElem}; /// A list of style properties. #[ty(cast)] #[derive(Default, PartialEq, Clone, Hash)] pub struct Styles(EcoVec>); impl Styles { /// Create a new, empty style list. pub const fn new() -> Self { Self(EcoVec::new()) } /// Whether this contains no styles. pub fn is_empty(&self) -> bool { self.0.is_empty() } /// Iterate over the contained styles. pub fn iter(&self) -> impl Iterator { self.0.iter().map(|style| &**style) } /// Iterate over the contained styles. pub fn as_slice(&self) -> &[LazyHash