@@ -189,6 +189,38 @@ where
189
189
}
190
190
}
191
191
192
+ /// Copies all elements from `self` into `dst`, using a volatile memcpy.
193
+ ///
194
+ /// The length of `dst` must be the same as `self`.
195
+ ///
196
+ /// The method is only available with the `nightly` feature enabled (requires a nightly
197
+ /// Rust compiler).
198
+ ///
199
+ /// ## Panics
200
+ ///
201
+ /// This function will panic if the two slices have different lengths.
202
+ ///
203
+ /// ## Examples
204
+ ///
205
+ /// Copying two elements from a volatile slice:
206
+ ///
207
+ /// ```
208
+ /// use volatile::Volatile;
209
+ ///
210
+ /// let src = [1, 2];
211
+ /// // the `Volatile` type does not work with arrays, so convert `src` to a slice
212
+ /// let slice = &src[..];
213
+ /// let volatile = Volatile::new(slice);
214
+ /// let mut dst = [5, 0, 0];
215
+ ///
216
+ /// // Because the slices have to be the same length,
217
+ /// // we slice the destination slice from three elements
218
+ /// // to two. It will panic if we don't do this.
219
+ /// volatile.copy_into_slice(&mut dst[1..]);
220
+ ///
221
+ /// assert_eq!(src, [1, 2]);
222
+ /// assert_eq!(dst, [5, 1, 2]);
223
+ /// ```
192
224
#[ cfg( feature = "nightly" ) ]
193
225
pub fn copy_into_slice ( & self , dst : & mut [ T ] )
194
226
where
@@ -212,13 +244,16 @@ where
212
244
///
213
245
/// The length of `src` must be the same as `self`.
214
246
///
247
+ /// The method is only available with the `nightly` feature enabled (requires a nightly
248
+ /// Rust compiler).
249
+ ///
215
250
/// ## Panics
216
251
///
217
252
/// This function will panic if the two slices have different lengths.
218
253
///
219
254
/// ## Examples
220
255
///
221
- /// Copying two elements from a slice into another :
256
+ /// Copying two elements from a slice into a volatile slice :
222
257
///
223
258
/// ```
224
259
/// use volatile::Volatile;
0 commit comments