[−][src]Trait genco::lang::dart::AsAny
Language-specific conversion trait implemented by all language items.
Required methods
fn as_any(&self) -> Any
Coerce trait into an enum that can be used for type-specific operations.
Examples
genco::impl_lang! { MyLang { type Config = (); type Import = dyn AsAny; type Format = (); } Import { fn as_import(&self) -> Option<&dyn AsAny> { Some(self) } } }; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] struct Import(usize); use genco::{quote, Tokens}; let t: Tokens<MyLang> = quote! { #(Import(0)) #(Import(1)) }; /// Find and compare all imports. assert_eq!(2, t.walk_imports().count()); for (i, import) in t.walk_imports().enumerate() { assert_eq!(Any::Import(&Import(i)), import.as_any()); }