pub struct RangeInclusive { /* private fields */ }
Expand description
A closed interval range [start, end]. The range describes a memory slot which is assigned by the VMM to a device.
§Example
use vm_allocator::RangeInclusive;
let r = RangeInclusive::new(0x0, 0x100).unwrap();
assert_eq!(r.len(), 0x101);
assert_eq!(r.start(), 0x0);
assert_eq!(r.end(), 0x100);
// Check if a region contains another region.
let other = RangeInclusive::new(0x50, 0x80).unwrap();
assert!(r.contains(&other));
// Check if a region overlaps with another one.
let other = RangeInclusive::new(0x99, 0x150).unwrap();
assert!(r.overlaps(&other));
Implementations§
Source§impl RangeInclusive
impl RangeInclusive
Sourcepub fn overlaps(&self, other: &RangeInclusive) -> bool
pub fn overlaps(&self, other: &RangeInclusive) -> bool
Returns true if the regions overlap.
Sourcepub fn contains(&self, other: &RangeInclusive) -> bool
pub fn contains(&self, other: &RangeInclusive) -> bool
Returns true if the current range contains the range passed as a parameter.
Trait Implementations§
Source§impl Clone for RangeInclusive
impl Clone for RangeInclusive
Source§fn clone(&self) -> RangeInclusive
fn clone(&self) -> RangeInclusive
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for RangeInclusive
impl Debug for RangeInclusive
Source§impl Hash for RangeInclusive
impl Hash for RangeInclusive
Source§impl Ord for RangeInclusive
impl Ord for RangeInclusive
Source§fn cmp(&self, other: &RangeInclusive) -> Ordering
fn cmp(&self, other: &RangeInclusive) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for RangeInclusive
impl PartialEq for RangeInclusive
Source§impl PartialOrd for RangeInclusive
impl PartialOrd for RangeInclusive
impl Copy for RangeInclusive
impl Eq for RangeInclusive
impl StructuralPartialEq for RangeInclusive
Auto Trait Implementations§
impl Freeze for RangeInclusive
impl RefUnwindSafe for RangeInclusive
impl Send for RangeInclusive
impl Sync for RangeInclusive
impl Unpin for RangeInclusive
impl UnwindSafe for RangeInclusive
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