File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ Core encoding and decoding interfaces.
20
20
21
21
use std:: at_vec;
22
22
use std:: hashmap:: { HashMap , HashSet } ;
23
+ use std:: rc:: Rc ;
23
24
use std:: trie:: { TrieMap , TrieSet } ;
24
25
use std:: vec;
25
26
use ringbuf:: RingBuf ;
@@ -405,6 +406,20 @@ impl<S:Encoder,T:Encodable<S>> Encodable<S> for @T {
405
406
}
406
407
}
407
408
409
+ impl < S : Encoder , T : Encodable < S > + Freeze > Encodable < S > for Rc < T > {
410
+ #[ inline]
411
+ fn encode ( & self , s : & mut S ) {
412
+ self . borrow ( ) . encode ( s)
413
+ }
414
+ }
415
+
416
+ impl < D : Decoder , T : Decodable < D > + Freeze > Decodable < D > for Rc < T > {
417
+ #[ inline]
418
+ fn decode ( d : & mut D ) -> Rc < T > {
419
+ Rc :: new ( Decodable :: decode ( d) )
420
+ }
421
+ }
422
+
408
423
impl < D : Decoder , T : Decodable < D > + ' static > Decodable < D > for @T {
409
424
fn decode ( d : & mut D ) -> @T {
410
425
@Decodable :: decode ( d)
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ use cast;
18
18
use container:: Container ;
19
19
use iter:: Iterator ;
20
20
use option:: { None , Option , Some } ;
21
+ use rc:: Rc ;
21
22
use str:: { Str , StrSlice } ;
22
23
use vec:: { Vector , ImmutableVector } ;
23
24
@@ -325,6 +326,13 @@ impl<A:IterBytes> IterBytes for @mut A {
325
326
}
326
327
}
327
328
329
+ impl < A : IterBytes > IterBytes for Rc < A > {
330
+ #[ inline]
331
+ fn iter_bytes ( & self , lsb0 : bool , f : Cb ) -> bool {
332
+ self . borrow ( ) . iter_bytes ( lsb0, f)
333
+ }
334
+ }
335
+
328
336
impl < A : IterBytes > IterBytes for ~A {
329
337
#[ inline]
330
338
fn iter_bytes ( & self , lsb0 : bool , f : Cb ) -> bool {
You can’t perform that action at this time.
0 commit comments