@@ -71,24 +71,6 @@ impl<T> ManuallyDrop<T> {
71
71
}
72
72
}
73
73
74
- /// Extracts the value from the ManuallyDrop container.
75
- /// Could also be implemented as Deref.
76
- #[unstable(feature = " manually_drop" , reason = " recently added" , issue = " 0" )]
77
- pub fn as_ref (& self ) -> & T {
78
- unsafe {
79
- & self . value
80
- }
81
- }
82
-
83
- /// Extracts the value from the ManuallyDrop container.
84
- /// Could also be implemented as a DerefMut.
85
- #[unstable(feature = " manually_drop" , reason = " recently added" , issue = " 0" )]
86
- pub fn as_mut (& mut self ) -> & mut T {
87
- unsafe {
88
- & mut self . value
89
- }
90
- }
91
-
92
74
/// Manually drops the contained value.
93
75
///
94
76
/// # Unsafety
@@ -97,11 +79,20 @@ impl<T> ManuallyDrop<T> {
97
79
/// with the value within invalid. The fact that this function does not consume the wrapper
98
80
/// does not statically prevent further reuse.
99
81
#[unstable(feature = " manually_drop" , reason = " recently added" , issue = " 0" )]
100
- pub unsafe fn manually_drop ( & mut self ) {
101
- ptr :: drop_in_place (& mut self . value)
82
+ pub unsafe fn drop ( slot : & mut ManuallyDrop < T > ) {
83
+ ptr :: drop_in_place (& mut slot . value)
102
84
}
103
85
}
104
86
87
+ impl <T > Deref for ManuallyDrop <T > {
88
+ type Target = T ;
89
+ // ...
90
+ }
91
+
92
+ impl <T > DerefMut for ManuallyDrop <T > {
93
+ // ...
94
+ }
95
+
105
96
// Other common impls such as `Debug for T: Debug`.
106
97
```
107
98
@@ -163,4 +154,4 @@ glance;
163
154
# Unresolved questions
164
155
[ unresolved ] : #unresolved-questions
165
156
166
- * Best way to expose value inside the wrapper .
157
+ None known .
0 commit comments