use std::cmp::{Ord, PartialOrd};
use std::fmt::{Display, Formatter, Result};
pub struct Element<T: Ord, P: PartialOrd> {
value: T,
priority: P,
}
impl<T: Ord, P: PartialOrd> Element<T, P> {
pub fn new(value: T, priority: P) -> Self {
Element { value, priority }
}
pub fn value(&self) -> &T {
&self.value
}
pub fn priority(&self) -> &P {
&self.priority
}
}
impl<T, P> Display for Element<T, P>
where
T: Ord + Display,
P: PartialOrd + Display,
{
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "<{}, {}>", self.value, self.priority)
}
}