]> git.lizzy.rs Git - rust.git/commitdiff
Clarify transmute_copy documentation example
authorAdam Schwalm <adamschwalm@gmail.com>
Sat, 16 Nov 2019 20:47:33 +0000 (14:47 -0600)
committerAdam Schwalm <adamschwalm@gmail.com>
Sat, 16 Nov 2019 20:47:33 +0000 (14:47 -0600)
src/libcore/mem/mod.rs

index dc7c36ff03c4e07062bf06e34103ce38be849160..fff010385c302e4cdb29a032cc5a327d5167c228 100644 (file)
@@ -744,11 +744,11 @@ pub fn drop<T>(_x: T) { }
 ///     bar: u8,
 /// }
 ///
-/// let foo_slice = [10u8];
+/// let foo_array = [10u8];
 ///
 /// unsafe {
-///     // Copy the data from 'foo_slice' and treat it as a 'Foo'
-///     let mut foo_struct: Foo = mem::transmute_copy(&foo_slice);
+///     // Copy the data from 'foo_array' and treat it as a 'Foo'
+///     let mut foo_struct: Foo = mem::transmute_copy(&foo_array);
 ///     assert_eq!(foo_struct.bar, 10);
 ///
 ///     // Modify the copied data
@@ -756,8 +756,8 @@ pub fn drop<T>(_x: T) { }
 ///     assert_eq!(foo_struct.bar, 20);
 /// }
 ///
-/// // The contents of 'foo_slice' should not have changed
-/// assert_eq!(foo_slice, [10]);
+/// // The contents of 'foo_array' should not have changed
+/// assert_eq!(foo_array, [10]);
 /// ```
 #[inline]
 #[stable(feature = "rust1", since = "1.0.0")]