trustformers_debug/streaming_debugger/
aggregationfunction_traits.rs1use super::types::*;
14use std::mem;
15
16impl std::hash::Hash for AggregationFunction {
17 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
18 mem::discriminant(self).hash(state);
19 match self {
20 AggregationFunction::Percentile(p) => {
21 p.to_bits().hash(state);
22 },
23 AggregationFunction::Custom(s) => s.hash(state),
24 _ => {},
25 }
26 }
27}
28
29impl Eq for AggregationFunction {}
30
31impl PartialEq for AggregationFunction {
32 fn eq(&self, other: &Self) -> bool {
33 match (self, other) {
34 (AggregationFunction::Percentile(a), AggregationFunction::Percentile(b)) => {
35 a.to_bits() == b.to_bits()
36 },
37 (AggregationFunction::Custom(a), AggregationFunction::Custom(b)) => a == b,
38 _ => mem::discriminant(self) == mem::discriminant(other),
39 }
40 }
41}