use std::any::{Any, TypeId}; use std::fmt::{self, Debug, Formatter}; use std::hash::{Hash, Hasher}; use std::{mem, ptr}; use comemo::Tracked; use ecow::{eco_vec, EcoString, EcoVec}; use smallvec::SmallVec; use typst_syntax::Span; use typst_utils::LazyHash; use crate::diag::{SourceResult, Trace, Tracepoint}; use crate::engine::Engine; use crate::foundations::{ cast, ty, Content, Context, Element, Func, NativeElement, Repr, Selector, }; 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