about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2019-11-17 13:36:25 +0900
committerGitHub <noreply@github.com>2019-11-17 13:36:25 +0900
commitf65cb87a09530ad8ab7b8dc0fb35519c17f29d4b (patch)
tree8bb989254c3f983a3212f28875f2536a8ccae745
parent750dd03a230d773b7395ff45b9fcebe795fe28aa (diff)
parent3407c49c41915e8850de621bd6ddf70d8b7540f5 (diff)
Rollup merge of #66477 - ALSchwalm:clarify-transmute-copy, r=Centril
Clarify transmute_copy documentation example

Currently the documentation for `transmute_copy` implies that the function accepts a slice due to the variable name chosen in the example. This is misleading as `foo_slice` is actually an array and `transmute_copy` cannot take an unsized type anyway.

This PR just clarifies things by renaming the variable used in the example.
-rw-r--r--src/libcore/mem/mod.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs
index dc7c36ff03c..fff010385c3 100644
--- a/src/libcore/mem/mod.rs
+++ b/src/libcore/mem/mod.rs
@@ -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")]