Coverage Report

Created: 2024-02-20 21:15

/builds/xfbs/cindy/common/src/label.rs
Line
Count
Source (jump to first uncovered line)
1
use derive_more::From;
2
use enum_kinds::EnumKind;
3
use serde::{Deserialize, Serialize};
4
use std::ops::Sub;
5
6
#[derive(
7
8
    
S0
erializ
e0
,
D0
eserializ
e0
,
Clone0
,
D0
ebu
g0
, Copy,
P2
artialE
q2
, Eq,
P0
artialOr
d0
,
O0
r
d0
,
H0
as
h0
, From,
E0
numKin
d0
,
8
)]
9
#[enum_kind(LabelKind)]
10
pub enum Label {
11
    Rectangle(Rectangle),
12
    Sequence(Sequence),
13
}
14
15
impl LabelKind {
16
3
    pub const fn name(&self) -> &'static str {
17
3
        match self {
18
2
            LabelKind::Rectangle => "rectangle",
19
1
            LabelKind::Sequence => "sequence",
20
        }
21
3
    }
22
}
23
24
2
#[derive(
S0
erializ
e0
,
D0
eserializ
e0
,
Clone0
,
Debug0
, Copy, PartialEq, Eq,
P0
artialOr
d0
,
O0
r
d0
,
Hash0
)]
25
pub struct Point<T> {
26
    pub x: T,
27
    pub y: T,
28
}
29
30
impl<T> Point<T> {
31
8
    pub fn new(x: T, y: T) -> Self {
32
8
        Self { x, y }
33
8
    }
34
}
35
36
1
#[derive(
S0
erializ
e0
,
D0
eserializ
e0
,
Clone0
,
Debug0
, Copy, PartialEq, Eq,
P0
artialOr
d0
,
O0
r
d0
,
Hash0
)]
37
pub struct Rectangle<T = u64> {
38
    pub start: Point<T>,
39
    pub end: Point<T>,
40
}
41
42
impl<T: Sub<Output = T> + Copy> Rectangle<T> {
43
0
    pub fn width(&self) -> T {
44
0
        self.end.x - self.start.x
45
0
    }
46
47
0
    pub fn height(&self) -> T {
48
0
        self.end.y - self.start.y
49
0
    }
50
}
51
52
1
#[derive(
S0
erializ
e0
,
D0
eserializ
e0
,
Clone0
,
Debug0
, Copy, PartialEq, Eq,
P0
artialOr
d0
,
O0
r
d0
,
Hash0
)]
53
pub struct Sequence<T = u64> {
54
    pub start: T,
55
    pub end: T,
56
}