@@ -482,7 +482,7 @@ where
482
482
///
483
483
/// The length of `dst` must be the same as `self`.
484
484
///
485
- /// The method is only available with the `nightly ` feature enabled (requires a nightly
485
+ /// The method is only available with the `unstable ` feature enabled (requires a nightly
486
486
/// Rust compiler).
487
487
///
488
488
/// ## Panics
@@ -533,7 +533,10 @@ where
533
533
///
534
534
/// The length of `src` must be the same as `self`.
535
535
///
536
- /// The method is only available with the `nightly` feature enabled (requires a nightly
536
+ /// This method is similar to the `slice::copy_from_slice` method of the standard library. The
537
+ /// difference is that this method performs a volatile copy.
538
+ ///
539
+ /// The method is only available with the `unstable` feature enabled (requires a nightly
537
540
/// Rust compiler).
538
541
///
539
542
/// ## Panics
@@ -581,6 +584,38 @@ where
581
584
}
582
585
}
583
586
587
+ /// Copies elements from one part of the slice to another part of itself, using a
588
+ /// volatile `memmove`.
589
+ ///
590
+ /// `src` is the range within `self` to copy from. `dest` is the starting index of the
591
+ /// range within `self` to copy to, which will have the same length as `src`. The two ranges
592
+ /// may overlap. The ends of the two ranges must be less than or equal to `self.len()`.
593
+ ///
594
+ /// This method is similar to the `slice::copy_within` method of the standard library. The
595
+ /// difference is that this method performs a volatile copy.
596
+ ///
597
+ /// This method is only available with the `unstable` feature enabled (requires a nightly
598
+ /// Rust compiler).
599
+ ///
600
+ /// ## Panics
601
+ ///
602
+ /// This function will panic if either range exceeds the end of the slice, or if the end
603
+ /// of `src` is before the start.
604
+ ///
605
+ /// ## Examples
606
+ ///
607
+ /// Copying four bytes within a slice:
608
+ ///
609
+ /// ```
610
+ /// use volatile::Volatile;
611
+ ///
612
+ /// let mut byte_array = *b"Hello, World!";
613
+ /// let mut slice: &mut [u8] = &mut byte_array[..];
614
+ /// let mut volatile = Volatile::new(slice);
615
+ ///
616
+ /// volatile.copy_within(1..5, 8);
617
+ ///
618
+ /// assert_eq!(&byte_array, b"Hello, Wello!");
584
619
#[ cfg( feature = "unstable" ) ]
585
620
pub fn copy_within ( & mut self , src : impl RangeBounds < usize > , dest : usize )
586
621
where
@@ -614,6 +649,25 @@ impl<R, A> Volatile<R, A>
614
649
where
615
650
R : Deref < Target = [ u8 ] > ,
616
651
{
652
+ /// Sets all elements of the byte slice to the given `value` using a volatile `memset`.
653
+ ///
654
+ /// This method is similar to the `slice::fill` method of the standard library, with the
655
+ /// difference that this method performs a volatile write operation. Another difference
656
+ /// is that this method is only available for byte slices (not general `&mut [T]` slices)
657
+ /// because there currently isn't a instrinsic function that allows non-`u8` values.
658
+ ///
659
+ /// This method is only available with the `unstable` feature enabled (requires a nightly
660
+ /// Rust compiler).
661
+ ///
662
+ /// ## Example
663
+ ///
664
+ /// ```rust
665
+ /// use volatile::Volatile;
666
+ ///
667
+ /// let mut buf = Volatile::new(vec![0; 10]);
668
+ /// buf.fill(1);
669
+ /// assert_eq!(buf.extract_inner(), vec![1; 10]);
670
+ /// ```
617
671
#[ cfg( feature = "unstable" ) ]
618
672
pub fn fill ( & mut self , value : u8 )
619
673
where
@@ -631,7 +685,7 @@ where
631
685
632
686
/// Methods for converting arrays to slices
633
687
///
634
- /// These methods are only available with the `nightly ` feature enabled (requires a nightly
688
+ /// These methods are only available with the `unstable ` feature enabled (requires a nightly
635
689
/// Rust compiler).
636
690
#[ cfg( feature = "unstable" ) ]
637
691
impl < R , A , T , const N : usize > Volatile < R , A >
0 commit comments