1use crate::pos::Pos;
2
3#[derive(Debug, Clone, Eq)]
5pub struct Label {
6 pub pos: Pos,
7 pub text: String,
8}
9
10impl Ord for Label {
11 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
12 self.pos.cmp(&other.pos)
13 }
14}
15
16impl PartialEq for Label {
17 fn eq(&self, other: &Self) -> bool {
18 self.pos == other.pos
19 }
20}
21
22impl PartialOrd for Label {
23 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
24 Some(self.cmp(other))
25 }
26}
27
28impl Label {
29 pub fn new_label(pos: impl Into<Pos>, text: impl Into<String>) -> Self {
31 let text: String = text.into();
32 Self {
33 pos: pos.into(),
34 text,
35 }
36 }
37}