diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-02-18 15:02:02 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-02-18 16:57:53 +0100 |
| commit | e01970b20a058ab1b4ebea916f229c9b706c84e4 (patch) | |
| tree | 5c5efc75abd6e607bd45a0602603231edf520503 /src/eval/class.rs | |
| parent | 05ec0f993b4a1b8481e494ee16285d23f000872f (diff) | |
Basic show rules
Diffstat (limited to 'src/eval/class.rs')
| -rw-r--r-- | src/eval/class.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/eval/class.rs b/src/eval/class.rs index 28e49a99..5601fb0b 100644 --- a/src/eval/class.rs +++ b/src/eval/class.rs @@ -1,3 +1,4 @@ +use std::any::TypeId; use std::fmt::{self, Debug, Formatter, Write}; use std::hash::{Hash, Hasher}; @@ -36,6 +37,7 @@ use crate::diag::TypResult; #[derive(Clone)] pub struct Class { name: &'static str, + id: TypeId, construct: fn(&mut Vm, &mut Args) -> TypResult<Value>, set: fn(&mut Args, &mut StyleMap) -> TypResult<()>, } @@ -48,6 +50,7 @@ impl Class { { Self { name, + id: TypeId::of::<T>(), construct: |ctx, args| { let mut styles = StyleMap::new(); T::set(args, &mut styles)?; @@ -63,6 +66,11 @@ impl Class { self.name } + /// The type id of the class. + pub fn id(&self) -> TypeId { + self.id + } + /// Return the class constructor as a function. pub fn constructor(&self) -> Func { Func::native(self.name, self.construct) |
