17
17
//! heap, for example). Moreover, a switch to, e.g., `P<'a, T>` would be easy
18
18
//! and mostly automated.
19
19
20
- use std:: fmt:: { self , Debug , Display } ;
20
+ use std:: fmt:: { self , Debug } ;
21
21
use std:: ops:: { Deref , DerefMut } ;
22
22
23
- use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
24
23
use rustc_serialize:: { Decodable , Decoder , Encodable , Encoder } ;
25
24
26
25
/// An owned smart pointer.
@@ -37,28 +36,10 @@ pub fn P<T>(value: T) -> P<T> {
37
36
}
38
37
39
38
impl < T > P < T > {
40
- /// Move out of the pointer.
41
- /// Intended for chaining transformations not covered by `map`.
42
- pub fn and_then < U , F > ( self , f : F ) -> U
43
- where
44
- F : FnOnce ( T ) -> U ,
45
- {
46
- f ( * self . ptr )
47
- }
48
-
49
- /// Equivalent to `and_then(|x| x)`.
39
+ /// Consume the `P` and return the wrapped value.
50
40
pub fn into_inner ( self ) -> T {
51
41
* self . ptr
52
42
}
53
-
54
- /// Optionally produce a new `P<T>` from `self` without reallocating.
55
- pub fn filter_map < F > ( mut self , f : F ) -> Option < P < T > >
56
- where
57
- F : FnOnce ( T ) -> Option < T > ,
58
- {
59
- * self . ptr = f ( * self . ptr ) ?;
60
- Some ( self )
61
- }
62
43
}
63
44
64
45
impl < T : ?Sized > Deref for P < T > {
@@ -87,18 +68,6 @@ impl<T: ?Sized + Debug> Debug for P<T> {
87
68
}
88
69
}
89
70
90
- impl < T : Display > Display for P < T > {
91
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
92
- Display :: fmt ( & * * self , f)
93
- }
94
- }
95
-
96
- impl < T > fmt:: Pointer for P < T > {
97
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
98
- fmt:: Pointer :: fmt ( & self . ptr , f)
99
- }
100
- }
101
-
102
71
impl < D : Decoder , T : Decodable < D > > Decodable < D > for P < T > {
103
72
fn decode ( d : & mut D ) -> P < T > {
104
73
P ( Decodable :: decode ( d) )
@@ -110,12 +79,3 @@ impl<S: Encoder, T: Encodable<S>> Encodable<S> for P<T> {
110
79
( * * self ) . encode ( s) ;
111
80
}
112
81
}
113
-
114
- impl < CTX , T > HashStable < CTX > for P < T >
115
- where
116
- T : ?Sized + HashStable < CTX > ,
117
- {
118
- fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
119
- ( * * self ) . hash_stable ( hcx, hasher) ;
120
- }
121
- }
0 commit comments