diff options
Diffstat (limited to 'kernel/src/util.rs')
-rw-r--r-- | kernel/src/util.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/src/util.rs b/kernel/src/util.rs index 29042c8..dbcb228 100644 --- a/kernel/src/util.rs +++ b/kernel/src/util.rs @@ -1,6 +1,6 @@ //! Miscellaneous utilities. -use core::mem::size_of; +use core::{mem::size_of, ops::Range}; #[cold] #[inline(always)] @@ -51,6 +51,11 @@ macro_rules! dbg { }; } +/// Returns whether the two ranges overlap. +pub fn ranges_overlap<T: Copy + Ord>(r1: &Range<T>, r2: &Range<T>) -> bool { + r1.start.max(r2.start) < r1.end.min(r2.end) +} + /// A trait for types that can be converted to from big-endian or little-endian byte slices. pub trait FromEndianBytes { /// Converts from a big-endian byte slice. |