orx_priority_queue/
node_key_ref.rs

1/// Trait representing (node, key) pairs stored on priority queues.
2pub trait NodeKeyRef<'a, N, K>
3where
4    N: 'a,
5    K: 'a,
6{
7    /// Returns a reference to the node.
8    fn node(&self) -> &'a N;
9
10    /// Returns a reference to the key/priority of the node.
11    fn key(&self) -> &'a K;
12}
13
14impl<'a, N, K> NodeKeyRef<'a, N, K> for &'a (N, K)
15where
16    N: 'a,
17    K: 'a,
18{
19    fn node(&self) -> &'a N {
20        &self.0
21    }
22    fn key(&self) -> &'a K {
23        &self.1
24    }
25}
26
27impl<'a, N, K> NodeKeyRef<'a, N, K> for (&'a N, &'a K)
28where
29    N: 'a,
30    K: 'a,
31{
32    fn node(&self) -> &'a N {
33        self.0
34    }
35    fn key(&self) -> &'a K {
36        self.1
37    }
38}