20 lines
396 B
Rust
20 lines
396 B
Rust
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)]
|
|
pub struct Interval {
|
|
pub start: u64,
|
|
pub end: u64,
|
|
}
|
|
|
|
impl Interval {
|
|
pub fn new(start: u64, end: u64) -> Interval {
|
|
Interval { start, end }
|
|
}
|
|
|
|
pub fn contains(&self, value: u64) -> bool {
|
|
self.start <= value && value <= self.end
|
|
}
|
|
|
|
pub fn len(&self) -> u64 {
|
|
self.end - self.start + 1
|
|
}
|
|
}
|