Skip to content

Commit 4e9170f

Browse files
committed
add missing access where bounds
1 parent 0d48fdd commit 4e9170f

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
@@ -544,6 +544,7 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {
544544
pub fn copy_into_slice(self, dst: &mut [T])
545545
where
546546
T: Copy,
547+
R: access::Safe,
547548
{
548549
let len = self.pointer.len();
549550
assert_eq!(
@@ -600,6 +601,7 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {
600601
pub fn copy_from_slice(self, src: &[T])
601602
where
602603
T: Copy,
604+
W: access::Safe,
603605
{
604606
let len = self.pointer.len();
605607
assert_eq!(
@@ -653,6 +655,8 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {
653655
pub fn copy_within(self, src: impl RangeBounds<usize>, dest: usize)
654656
where
655657
T: Copy,
658+
R: access::Safe,
659+
W: access::Safe,
656660
{
657661
let len = self.pointer.len();
658662
// implementation taken from https://github.com/rust-lang/rust/blob/683d1bcd405727fcc9209f64845bd3b9104878b8/library/core/src/slice/mod.rs#L2726-L2738
@@ -828,7 +832,7 @@ impl<'a, T, R, W> VolatilePtr<'a, [T], Access<R, W>> {
828832

829833
/// Methods for volatile byte slices
830834
#[cfg(feature = "unstable")]
831-
impl<A> VolatilePtr<'_, [u8], A> {
835+
impl<R, W> VolatilePtr<'_, [u8], Access<R, W>> {
832836
/// Sets all elements of the byte slice to the given `value` using a volatile `memset`.
833837
///
834838
/// This method is similar to the `slice::fill` method of the standard library, with the
@@ -850,7 +854,10 @@ impl<A> VolatilePtr<'_, [u8], A> {
850854
/// buf.fill(1);
851855
/// assert_eq!(unsafe { buf.as_ptr().as_mut() }, &mut vec![1; 10]);
852856
/// ```
853-
pub fn fill(self, value: u8) {
857+
pub fn fill(self, value: u8)
858+
where
859+
W: access::Safe,
860+
{
854861
unsafe {
855862
intrinsics::volatile_set_memory(self.pointer.as_mut_ptr(), value, self.pointer.len());
856863
}

0 commit comments

Comments
 (0)