File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -73,9 +73,9 @@ impl<T: ?Sized> !Send for *mut T { }
7373/// impl Foo for Impl { }
7474/// impl Bar for Impl { }
7575///
76- /// let x: &Foo = &Impl; // OK
77- /// // let y: &Bar = &Impl; // error: the trait `Bar` cannot
78- /// // be made into an object
76+ /// let x: &dyn Foo = &Impl; // OK
77+ /// // let y: &dyn Bar = &Impl; // error: the trait `Bar` cannot
78+ /// // be made into an object
7979/// ```
8080///
8181/// [trait object]: ../../book/ch17-02-trait-objects.html
Original file line number Diff line number Diff line change @@ -510,6 +510,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
510510/// A simple example:
511511///
512512/// ```
513+ /// #![feature(mem_take)]
514+ ///
513515/// use std::mem;
514516///
515517/// let mut v: Vec<i32> = vec![1, 2];
@@ -540,7 +542,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
540542/// `self`, allowing it to be returned:
541543///
542544/// ```
543- /// # #![allow(dead_code)]
545+ /// #![feature(mem_take)]
546+ ///
544547/// use std::mem;
545548///
546549/// # struct Buffer<T> { buf: Vec<T> }
Original file line number Diff line number Diff line change 5353/// let value: i32 = 123;
5454///
5555/// // let the compiler make a trait object
56- /// let object: &Foo = &value;
56+ /// let object: &dyn Foo = &value;
5757///
5858/// // look at the raw representation
5959/// let raw_object: raw::TraitObject = unsafe { mem::transmute(object) };
6565///
6666/// // construct a new object, pointing to a different `i32`, being
6767/// // careful to use the `i32` vtable from `object`
68- /// let synthesized: &Foo = unsafe {
68+ /// let synthesized: &dyn Foo = unsafe {
6969/// mem::transmute(raw::TraitObject {
7070/// data: &other_value as *const _ as *mut (),
7171/// vtable: raw_object.vtable,
You can’t perform that action at this time.
0 commit comments