use std::any::{Any, TypeId}; use std::sync::Arc; use comemo::Tracked; use ecow::{eco_format, EcoString, EcoVec}; use smallvec::SmallVec; use crate::diag::{bail, HintedStrResult, StrResult}; use crate::foundations::{ cast, func, repr, scope, ty, CastInfo, Content, Context, Dict, Element, FromValue, Func, Label, Reflect, Regex, Repr, Str, StyleChain, Type, Value, }; use crate::introspection::{Introspector, Locatable, Location}; use crate::symbols::Symbol; use crate::text::TextElem; /// A helper macro to create a field selector used in [`Selector::Elem`] /// /// ```ignore /// select_where!(SequenceElem, Children => vec![]); /// ``` #[macro_export] #[doc(hidden)] macro_rules! __select_where { ($ty:ty $(, $field:ident => $value:expr)* $(,)?) => {{ #[allow(unused_mut)] let mut fields = ::smallvec::SmallVec::new(); $( fields.push(( <$ty as $crate::foundations::Fields>::Enum::$field as u8, $crate::foundations::IntoValue::into_value($value), )); )* $crate::foundations::Selector::Elem( <$ty as $crate::foundations::NativeElement>::elem(), Some(fields), ) }}; } #[doc(inline)] pub use crate::__select_where as select_where; /// A filter for selecting elements within the document. /// /// You can construct a selector in the following ways: /// - you can use an element [function]($function) /// - you can filter for an element function with /// [specific fields]($function.where) /// - you can use a [string]($str) or [regular expression]($regex) /// - you can use a [`{