code review fixes

This commit is contained in:
Pat Hickey
2020-09-02 13:39:32 -07:00
parent 82b3672956
commit b63e974014

View File

@@ -449,7 +449,7 @@ impl<'a, T> GuestPtr<'a, [T]> {
self.pointer.0
}
/// For slices, returns the length of the slice, in units.
/// For slices, returns the length of the slice, in elements.
pub fn len(&self) -> u32 {
self.pointer.1
}
@@ -552,6 +552,9 @@ impl<'a, T> GuestPtr<'a, [T]> {
}
pub fn get_range(&self, r: std::ops::Range<u32>) -> Option<GuestPtr<'a, [T]>> {
if r.end < r.start {
return None;
}
let range_length = r.end - r.start;
if r.start <= self.len() && r.end <= self.len() {
Some(GuestPtr::new(