about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-03-13 17:49:15 +0000
committerbors <bors@rust-lang.org>2015-03-13 17:49:15 +0000
commit9eb69abad8ffbce840e7dc7038ddea434dc987f1 (patch)
tree217b64e9e1271d2be83dfb091044432928861520 /src/libcore
parentee7696383f3423cdd17373ff9e75c01acd8e3417 (diff)
parent40b64645fecbee4e11da1ea4328c1b1ab4b9b8a0 (diff)
downloadrust-9eb69abad8ffbce840e7dc7038ddea434dc987f1.tar.gz
rust-9eb69abad8ffbce840e7dc7038ddea434dc987f1.zip
Auto merge of #23337 - Manishearth:rollup, r=Manishearth
r? @Manishearth
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/hash/mod.rs4
-rw-r--r--src/libcore/ptr.rs29
2 files changed, 17 insertions, 16 deletions
diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs
index 4b545435ea1..fdc0020dfcd 100644
--- a/src/libcore/hash/mod.rs
+++ b/src/libcore/hash/mod.rs
@@ -70,9 +70,7 @@ mod sip;
 /// A hashable type.
 ///
 /// The `H` type parameter is an abstract hash state that is used by the `Hash`
-/// to compute the hash. Specific implementations of this trait may specialize
-/// for particular instances of `H` in order to be able to optimize the hashing
-/// behavior.
+/// to compute the hash.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait Hash {
     /// Feeds this value into the state given, updating the hasher as necessary.
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index 0625c3c7d60..32123a8271c 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -33,31 +33,34 @@
 //! let my_speed_ptr: *mut i32 = &mut my_speed;
 //! ```
 //!
+//! To get a pointer to a boxed value, dereference the box:
+//!
+//! ```
+//! let my_num: Box<i32> = Box::new(10);
+//! let my_num_ptr: *const i32 = &*my_num;
+//! let mut my_speed: Box<i32> = Box::new(88);
+//! let my_speed_ptr: *mut i32 = &mut *my_speed;
+//! ```
+//!
 //! This does not take ownership of the original allocation
 //! and requires no resource management later,
 //! but you must not use the pointer after its lifetime.
 //!
-//! ## 2. Transmute an owned box (`Box<T>`).
+//! ## 2. Consume a box (`Box<T>`).
 //!
-//! The `transmute` function takes, by value, whatever it's given
-//! and returns it as whatever type is requested, as long as the
-//! types are the same size. Because `Box<T>` and `*mut T` have the same
-//! representation they can be trivially,
-//! though unsafely, transformed from one type to the other.
+//! The `into_raw` function consumes a box and returns
+//! the raw pointer. It doesn't destroy `T` or deallocate any memory.
 //!
 //! ```
-//! use std::mem;
+//! use std::boxed;
 //!
 //! unsafe {
-//!     let my_num: Box<i32> = Box::new(10);
-//!     let my_num: *const i32 = mem::transmute(my_num);
 //!     let my_speed: Box<i32> = Box::new(88);
-//!     let my_speed: *mut i32 = mem::transmute(my_speed);
+//!     let my_speed: *mut i32 = boxed::into_raw(my_speed);
 //!
 //!     // By taking ownership of the original `Box<T>` though
-//!     // we are obligated to transmute it back later to be destroyed.
-//!     drop(mem::transmute::<_, Box<i32>>(my_speed));
-//!     drop(mem::transmute::<_, Box<i32>>(my_num));
+//!     // we are obligated to put it together later to be destroyed.
+//!     drop(Box::from_raw(my_speed));
 //! }
 //! ```
 //!