Skip to content

Commit 406e266

Browse files
authored
Merge pull request #25 from hawkw/eliza/update-features
Remove the `const_generics` feature flag
2 parents 831246d + 9894588 commit 406e266

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/lib.rs

+9-15
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
88
#![no_std]
99
#![cfg_attr(feature = "unstable", feature(core_intrinsics))]
10-
#![cfg_attr(feature = "unstable", feature(const_generics))]
1110
#![cfg_attr(feature = "unstable", feature(slice_range))]
1211
#![cfg_attr(feature = "unstable", allow(incomplete_features))]
1312
#![cfg_attr(all(feature = "unstable", test), feature(slice_as_chunks))]
@@ -684,10 +683,6 @@ where
684683
}
685684

686685
/// Methods for converting arrays to slices
687-
///
688-
/// These methods are only available with the `unstable` feature enabled (requires a nightly
689-
/// Rust compiler).
690-
#[cfg(feature = "unstable")]
691686
impl<R, A, T, const N: usize> Volatile<R, A>
692687
where
693688
R: Deref<Target = [T; N]>,
@@ -698,21 +693,21 @@ where
698693
///
699694
/// ## Example
700695
///
701-
/// Copying two elements from a volatile array reference using `copy_into_slice`:
696+
/// Reading a subslice from a volatile array reference using `index`:
702697
///
703698
/// ```
704699
/// use volatile::Volatile;
705700
///
706-
/// let src = [1, 2];
701+
/// let src = [1, 2, 3, 4];
707702
/// let volatile = Volatile::new(&src);
708-
/// let mut dst = [0, 0];
709703
///
710-
/// // convert the `Volatile<&[i32; 2]>` array reference to a `Volatile<&[i32]>` slice
704+
/// // convert the `Volatile<&[i32; 4]>` array reference to a `Volatile<&[i32]>` slice
711705
/// let volatile_slice = volatile.as_slice();
712706
/// // we can now use the slice methods
713-
/// volatile_slice.copy_into_slice(&mut dst);
707+
/// let subslice = volatile_slice.index(2..);
714708
///
715-
/// assert_eq!(dst, [1, 2]);
709+
/// assert_eq!(subslice.index(0).read(), 3);
710+
/// assert_eq!(subslice.index(1).read(), 4);
716711
/// ```
717712
pub fn as_slice(&self) -> Volatile<&[T], A> {
718713
self.map(|array| &array[..])
@@ -724,21 +719,20 @@ where
724719
///
725720
/// ## Example
726721
///
727-
/// Copying two elements from a slice into a mutable array reference:
722+
/// Writing to an index of a mutable array reference:
728723
///
729724
/// ```
730725
/// use volatile::Volatile;
731726
///
732-
/// let src = [1, 2, 3, 4];
733727
/// let mut dst = [0, 0];
734728
/// let mut volatile = Volatile::new(&mut dst);
735729
///
736730
/// // convert the `Volatile<&mut [i32; 2]>` array reference to a `Volatile<&mut [i32]>` slice
737731
/// let mut volatile_slice = volatile.as_mut_slice();
738732
/// // we can now use the slice methods
739-
/// volatile_slice.copy_from_slice(&src[2..]);
733+
/// volatile_slice.index_mut(1).write(1);
740734
///
741-
/// assert_eq!(dst, [3, 4]);
735+
/// assert_eq!(dst, [0, 1]);
742736
/// ```
743737
pub fn as_mut_slice(&mut self) -> Volatile<&mut [T], A>
744738
where

0 commit comments

Comments
 (0)