pub struct Range {
pub min: u64,
pub max: u64,
}
Expand description
Represent a closed range [min, max]
.
Fields§
§min: u64
§max: u64
Implementations§
Source§impl Range
impl Range
Sourcepub fn new_point<T>(value: T) -> Self
pub fn new_point<T>(value: T) -> Self
Create a instance of Range
containing only the point value
.
Sourcepub fn intersect(&self, other: &Range) -> bool
pub fn intersect(&self, other: &Range) -> bool
Check whether two Range objects intersect with each other.
Sourcepub fn contain(&self, other: &Range) -> bool
pub fn contain(&self, other: &Range) -> bool
Check whether another Range object is fully covered by this range.
Sourcepub fn align_to(&self, align: u64) -> Option<Range>
pub fn align_to(&self, align: u64) -> Option<Range>
Create a new instance of Range with min
aligned to align
.
§Examples
extern crate dbs_allocator;
use dbs_allocator::Range;
let a = Range::new(2u32, 6u32);
assert_eq!(a.align_to(0), Some(Range::new(2u32, 6u32)));
assert_eq!(a.align_to(1), Some(Range::new(2u16, 6u16)));
assert_eq!(a.align_to(2), Some(Range::new(2u64, 6u64)));
assert_eq!(a.align_to(4), Some(Range::new(4u8, 6u8)));
assert_eq!(a.align_to(8), None);
assert_eq!(a.align_to(3), None);
let b = Range::new(2u8, 2u8);
assert_eq!(b.align_to(2), Some(Range::new(2u8, 2u8)));
Trait Implementations§
Source§impl Ord for Range
impl Ord for Range
Source§impl PartialOrd for Range
impl PartialOrd for Range
impl Copy for Range
impl Eq for Range
impl StructuralPartialEq for Range
Auto Trait Implementations§
impl Freeze for Range
impl RefUnwindSafe for Range
impl Send for Range
impl Sync for Range
impl Unpin for Range
impl UnwindSafe for Range
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more