Update structure of modules
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#[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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user