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