rshyper_core/traits/
nodes.rs1use crate::{VertexId, Weight};
6
7pub trait HyperNode<Idx> {
9 fn index(&self) -> &VertexId<Idx>;
10}
11
12pub trait HashNode<Idx>: HyperNode<Idx> + Eq + core::hash::Hash {
15 private!();
16}
17
18pub trait Weighted<T> {
19 fn weight(&self) -> &Weight<T>;
20
21 fn weight_mut(&mut self) -> &mut Weight<T>;
22}
23
24impl<T> Weighted<T> for T
28where
29 T: AsRef<Weight<T>> + AsMut<Weight<T>>,
30{
31 fn weight(&self) -> &Weight<T> {
32 self.as_ref()
33 }
34
35 fn weight_mut(&mut self) -> &mut Weight<T> {
36 self.as_mut()
37 }
38}
39
40impl<T, Idx> HashNode<Idx> for T
41where
42 T: HyperNode<Idx> + Eq + core::hash::Hash,
43{
44 seal!();
45}
46
47impl<T, Idx> HyperNode<Idx> for T
48where
49 T: core::borrow::Borrow<VertexId<Idx>>,
50{
51 fn index(&self) -> &VertexId<Idx> {
52 self.borrow()
53 }
54}