Skip to content

Commit fb7e6a5

Browse files
committed
Use map/map_mut for index/index_mut implementation
1 parent 4ba88d3 commit fb7e6a5

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/lib.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,7 @@ where
396396
I: SliceIndex<[T]>,
397397
T: 'a,
398398
{
399-
Volatile {
400-
reference: self.reference.index(index),
401-
access: self.access,
402-
}
399+
self.map(|slice| slice.index(index))
403400
}
404401

405402
pub fn index_mut<'a, I>(&'a mut self, index: I) -> Volatile<&mut I::Output, A>
@@ -408,10 +405,7 @@ where
408405
R: DerefMut,
409406
T: 'a,
410407
{
411-
Volatile {
412-
reference: self.reference.index_mut(index),
413-
access: self.access,
414-
}
408+
self.map_mut(|slice| slice.index_mut(index))
415409
}
416410

417411
/// Copies all elements from `self` into `dst`, using a volatile memcpy.

0 commit comments

Comments
 (0)