@@ -83,10 +83,10 @@ impl<T: 'static> P<T> {
8383 }
8484}
8585
86- impl < T > Deref for P < T > {
86+ impl < T : ? Sized > Deref for P < T > {
8787 type Target = T ;
8888
89- fn deref < ' a > ( & ' a self ) -> & ' a T {
89+ fn deref ( & self ) -> & T {
9090 & self . ptr
9191 }
9292}
@@ -97,11 +97,12 @@ impl<T: 'static + Clone> Clone for P<T> {
9797 }
9898}
9999
100- impl < T : Debug > Debug for P < T > {
100+ impl < T : ? Sized + Debug > Debug for P < T > {
101101 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
102- Debug :: fmt ( & * * self , f)
102+ Debug :: fmt ( & self . ptr , f)
103103 }
104104}
105+
105106impl < T : Display > Display for P < T > {
106107 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
107108 Display :: fmt ( & * * self , f)
@@ -126,19 +127,8 @@ impl<T: Encodable> Encodable for P<T> {
126127 }
127128}
128129
129-
130- impl < T : fmt:: Debug > fmt:: Debug for P < [ T ] > {
131- fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
132- self . ptr . fmt ( fmt)
133- }
134- }
135-
136130impl < T > P < [ T ] > {
137131 pub fn new ( ) -> P < [ T ] > {
138- P :: empty ( )
139- }
140-
141- pub fn empty ( ) -> P < [ T ] > {
142132 P { ptr : Default :: default ( ) }
143133 }
144134
@@ -151,31 +141,11 @@ impl<T> P<[T]> {
151141 pub fn into_vec ( self ) -> Vec < T > {
152142 self . ptr . into_vec ( )
153143 }
154-
155- pub fn as_slice < ' a > ( & ' a self ) -> & ' a [ T ] {
156- & self . ptr
157- }
158-
159- pub fn move_iter ( self ) -> vec:: IntoIter < T > {
160- self . into_vec ( ) . into_iter ( )
161- }
162-
163- pub fn map < U , F : FnMut ( & T ) -> U > ( & self , f : F ) -> P < [ U ] > {
164- self . iter ( ) . map ( f) . collect ( )
165- }
166- }
167-
168- impl < T > Deref for P < [ T ] > {
169- type Target = [ T ] ;
170-
171- fn deref ( & self ) -> & [ T ] {
172- self . as_slice ( )
173- }
174144}
175145
176146impl < T > Default for P < [ T ] > {
177147 fn default ( ) -> P < [ T ] > {
178- P :: empty ( )
148+ P :: new ( )
179149 }
180150}
181151
0 commit comments