Skip to content

Commit aa93fb9

Browse files
committed
add missing access where bounds
1 parent 167adec commit aa93fb9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/lib.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {
535535
pub fn copy_into_slice(&self, dst: &mut [T])
536536
where
537537
T: Copy,
538+
R: access::Safe,
538539
{
539540
let len = self.pointer.len();
540541
assert_eq!(
@@ -591,6 +592,7 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {
591592
pub fn copy_from_slice(&mut self, src: &[T])
592593
where
593594
T: Copy,
595+
W: access::Safe,
594596
{
595597
let len = self.pointer.len();
596598
assert_eq!(
@@ -644,6 +646,8 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {
644646
pub fn copy_within(&mut self, src: impl RangeBounds<usize>, dest: usize)
645647
where
646648
T: Copy,
649+
R: access::Safe,
650+
W: access::Safe,
647651
{
648652
let len = self.pointer.len();
649653
// implementation taken from https://github.com/rust-lang/rust/blob/683d1bcd405727fcc9209f64845bd3b9104878b8/library/core/src/slice/mod.rs#L2726-L2738
@@ -819,7 +823,7 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {
819823

820824
/// Methods for volatile byte slices
821825
#[cfg(feature = "unstable")]
822-
impl<A> VolatilePtr<'_, [u8], A> {
826+
impl<R, W> VolatilePtr<'_, [u8], Access<R, W>> {
823827
/// Sets all elements of the byte slice to the given `value` using a volatile `memset`.
824828
///
825829
/// This method is similar to the `slice::fill` method of the standard library, with the
@@ -841,7 +845,10 @@ impl<A> VolatilePtr<'_, [u8], A> {
841845
/// buf.fill(1);
842846
/// assert_eq!(unsafe { buf.as_ptr().as_mut() }, &mut vec![1; 10]);
843847
/// ```
844-
pub fn fill(&mut self, value: u8) {
848+
pub fn fill(&mut self, value: u8)
849+
where
850+
W: access::Safe,
851+
{
845852
unsafe {
846853
intrinsics::volatile_set_memory(self.pointer.as_mut_ptr(), value, self.pointer.len());
847854
}

0 commit comments

Comments
 (0)