summaryrefslogtreecommitdiff
path: root/src/eval/class.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-02-17 12:50:54 +0100
committerLaurenz <laurmaedje@gmail.com>2022-02-17 12:50:54 +0100
commit91e45458e3d4c1e15660570841f0263f3d891278 (patch)
treea0b86374c083fc758110c55c24fd4bef21ac2caa /src/eval/class.rs
parentc7a9bac99224af9673f26ec140af48e1728fe3b5 (diff)
Make values hashable
Diffstat (limited to 'src/eval/class.rs')
-rw-r--r--src/eval/class.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/eval/class.rs b/src/eval/class.rs
index acdf38e6..c4880e9a 100644
--- a/src/eval/class.rs
+++ b/src/eval/class.rs
@@ -1,4 +1,5 @@
use std::fmt::{self, Debug, Formatter, Write};
+use std::hash::{Hash, Hasher};
use super::{Args, EvalContext, Func, StyleMap, Template, Value};
use crate::diag::TypResult;
@@ -103,6 +104,13 @@ impl PartialEq for Class {
}
}
+impl Hash for Class {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ (self.construct as usize).hash(state);
+ (self.set as usize).hash(state);
+ }
+}
+
/// Construct an instance of a class.
pub trait Construct {
/// Construct an instance of this class from the arguments.