File tree 3 files changed +9
-6
lines changed
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 { }
73
73
/// impl Foo for Impl { }
74
74
/// impl Bar for Impl { }
75
75
///
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
79
79
/// ```
80
80
///
81
81
/// [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) {
510
510
/// A simple example:
511
511
///
512
512
/// ```
513
+ /// #![feature(mem_take)]
514
+ ///
513
515
/// use std::mem;
514
516
///
515
517
/// let mut v: Vec<i32> = vec![1, 2];
@@ -540,7 +542,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
540
542
/// `self`, allowing it to be returned:
541
543
///
542
544
/// ```
543
- /// # #![allow(dead_code)]
545
+ /// #![feature(mem_take)]
546
+ ///
544
547
/// use std::mem;
545
548
///
546
549
/// # struct Buffer<T> { buf: Vec<T> }
Original file line number Diff line number Diff line change 53
53
/// let value: i32 = 123;
54
54
///
55
55
/// // let the compiler make a trait object
56
- /// let object: &Foo = &value;
56
+ /// let object: &dyn Foo = &value;
57
57
///
58
58
/// // look at the raw representation
59
59
/// let raw_object: raw::TraitObject = unsafe { mem::transmute(object) };
65
65
///
66
66
/// // construct a new object, pointing to a different `i32`, being
67
67
/// // careful to use the `i32` vtable from `object`
68
- /// let synthesized: &Foo = unsafe {
68
+ /// let synthesized: &dyn Foo = unsafe {
69
69
/// mem::transmute(raw::TraitObject {
70
70
/// data: &other_value as *const _ as *mut (),
71
71
/// vtable: raw_object.vtable,
You can’t perform that action at this time.
0 commit comments