@@ -1810,7 +1810,20 @@ impl<R: Read> Decoder<R> {
18101810 }
18111811 }
18121812
1813- // TODO: Add an ability to borrow underlying reader and to destruct this decoder.
1813+ /// Gets a reference to the underlying reader in this decoder.
1814+ pub fn get_ref ( & self ) -> & R {
1815+ & self . rd
1816+ }
1817+
1818+ /// Gets a mutable reference to the underlying reader in this decoder.
1819+ pub fn get_mut ( & mut self ) -> & mut R {
1820+ & mut self . rd
1821+ }
1822+
1823+ /// Consumes this decoder returning the underlying reader.
1824+ pub fn into_inner ( self ) -> R {
1825+ self . rd
1826+ }
18141827}
18151828
18161829/// Unstable: docs; examples; incomplete
@@ -2200,11 +2213,26 @@ impl<R: Read> Deserializer<R> {
22002213 }
22012214 }
22022215
2216+ /// Gets a reference to the underlying reader in this decoder.
2217+ pub fn get_ref ( & self ) -> & R {
2218+ & self . rd
2219+ }
2220+
2221+ /// Gets a mutable reference to the underlying reader in this decoder.
2222+ pub fn get_mut ( & mut self ) -> & mut R {
2223+ & mut self . rd
2224+ }
2225+
2226+ /// Consumes this decoder returning the underlying reader.
2227+ pub fn into_inner ( self ) -> R {
2228+ self . rd
2229+ }
2230+
22032231 fn read_str < V > ( & mut self , len : u32 , mut visitor : V ) -> Result < V :: Value >
22042232 where V : serde:: de:: Visitor
22052233 {
22062234 self . buf . clear ( ) ;
2207- self . buf . extend ( ( 0 .. len) . map ( |_| 0 ) ) ;
2235+ self . buf . extend ( ( 0 .. len) . map ( |_| 0 ) ) ;
22082236 visitor. visit_str ( try!( read_str_data ( & mut self . rd , len, & mut self . buf [ ..] ) ) )
22092237 }
22102238
@@ -2242,8 +2270,6 @@ impl<R: Read> Deserializer<R> {
22422270
22432271 visitor. visit_bytes ( & mut self . buf [ ..] )
22442272 }
2245-
2246- // TODO: Add an ability to borrow underlying reader and to destruct this decoder.
22472273}
22482274
22492275/// Unstable: docs; examples; incomplete
0 commit comments