@@ -201,7 +201,7 @@ use std::string;
201201use std:: { char, f64, fmt, str} ;
202202use std;
203203
204- use Encodable ;
204+ use crate :: Encodable ;
205205
206206/// Represents a json value
207207#[ derive( Clone , PartialEq , PartialOrd , Debug ) ]
@@ -221,8 +221,8 @@ pub type Object = BTreeMap<string::String, Json>;
221221
222222pub struct PrettyJson < ' a > { inner : & ' a Json }
223223
224- pub struct AsJson < ' a , T : ' a > { inner : & ' a T }
225- pub struct AsPrettyJson < ' a , T : ' a > { inner : & ' a T , indent : Option < usize > }
224+ pub struct AsJson < ' a , T > { inner : & ' a T }
225+ pub struct AsPrettyJson < ' a , T > { inner : & ' a T , indent : Option < usize > }
226226
227227/// The errors that can arise while parsing a JSON stream.
228228#[ derive( Clone , Copy , PartialEq , Debug ) ]
@@ -295,18 +295,18 @@ pub fn error_str(error: ErrorCode) -> &'static str {
295295}
296296
297297/// Shortcut function to decode a JSON `&str` into an object
298- pub fn decode < T : :: Decodable > ( s : & str ) -> DecodeResult < T > {
298+ pub fn decode < T : crate :: Decodable > ( s : & str ) -> DecodeResult < T > {
299299 let json = match from_str ( s) {
300300 Ok ( x) => x,
301301 Err ( e) => return Err ( ParseError ( e) )
302302 } ;
303303
304304 let mut decoder = Decoder :: new ( json) ;
305- :: Decodable :: decode ( & mut decoder)
305+ crate :: Decodable :: decode ( & mut decoder)
306306}
307307
308308/// Shortcut function to encode a `T` into a JSON `String`
309- pub fn encode < T : :: Encodable > ( object : & T ) -> Result < string:: String , EncoderError > {
309+ pub fn encode < T : crate :: Encodable > ( object : & T ) -> Result < string:: String , EncoderError > {
310310 let mut s = String :: new ( ) ;
311311 {
312312 let mut encoder = Encoder :: new ( & mut s) ;
@@ -316,7 +316,7 @@ pub fn encode<T: ::Encodable>(object: &T) -> Result<string::String, EncoderError
316316}
317317
318318impl fmt:: Display for ErrorCode {
319- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
319+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
320320 error_str ( * self ) . fmt ( f)
321321 }
322322}
@@ -326,14 +326,14 @@ fn io_error_to_error(io: io::Error) -> ParserError {
326326}
327327
328328impl fmt:: Display for ParserError {
329- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
329+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
330330 // FIXME this should be a nicer error
331331 fmt:: Debug :: fmt ( self , f)
332332 }
333333}
334334
335335impl fmt:: Display for DecoderError {
336- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
336+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
337337 // FIXME this should be a nicer error
338338 fmt:: Debug :: fmt ( self , f)
339339 }
@@ -344,7 +344,7 @@ impl std::error::Error for DecoderError {
344344}
345345
346346impl fmt:: Display for EncoderError {
347- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
347+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
348348 // FIXME this should be a nicer error
349349 fmt:: Debug :: fmt ( self , f)
350350 }
@@ -477,7 +477,7 @@ macro_rules! emit_enquoted_if_mapkey {
477477 } )
478478}
479479
480- impl < ' a > :: Encoder for Encoder < ' a > {
480+ impl < ' a > crate :: Encoder for Encoder < ' a > {
481481 type Error = EncoderError ;
482482
483483 fn emit_unit ( & mut self ) -> EncodeResult {
@@ -727,7 +727,7 @@ impl<'a> PrettyEncoder<'a> {
727727 }
728728}
729729
730- impl < ' a > :: Encoder for PrettyEncoder < ' a > {
730+ impl < ' a > crate :: Encoder for PrettyEncoder < ' a > {
731731 type Error = EncoderError ;
732732
733733 fn emit_unit ( & mut self ) -> EncodeResult {
@@ -997,7 +997,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> {
997997}
998998
999999impl Encodable for Json {
1000- fn encode < E : :: Encoder > ( & self , e : & mut E ) -> Result < ( ) , E :: Error > {
1000+ fn encode < E : crate :: Encoder > ( & self , e : & mut E ) -> Result < ( ) , E :: Error > {
10011001 match * self {
10021002 Json :: I64 ( v) => v. encode ( e) ,
10031003 Json :: U64 ( v) => v. encode ( e) ,
@@ -1013,20 +1013,20 @@ impl Encodable for Json {
10131013
10141014/// Create an `AsJson` wrapper which can be used to print a value as JSON
10151015/// on-the-fly via `write!`
1016- pub fn as_json < T > ( t : & T ) -> AsJson < T > {
1016+ pub fn as_json < T > ( t : & T ) -> AsJson < ' _ , T > {
10171017 AsJson { inner : t }
10181018}
10191019
10201020/// Create an `AsPrettyJson` wrapper which can be used to print a value as JSON
10211021/// on-the-fly via `write!`
1022- pub fn as_pretty_json < T > ( t : & T ) -> AsPrettyJson < T > {
1022+ pub fn as_pretty_json < T > ( t : & T ) -> AsPrettyJson < ' _ , T > {
10231023 AsPrettyJson { inner : t, indent : None }
10241024}
10251025
10261026impl Json {
10271027 /// Borrow this json object as a pretty object to generate a pretty
10281028 /// representation for it via `Display`.
1029- pub fn pretty ( & self ) -> PrettyJson {
1029+ pub fn pretty ( & self ) -> PrettyJson < ' _ > {
10301030 PrettyJson { inner : self }
10311031 }
10321032
@@ -1300,7 +1300,7 @@ impl Stack {
13001300 /// Provides access to the StackElement at a given index.
13011301 /// lower indices are at the bottom of the stack while higher indices are
13021302 /// at the top.
1303- pub fn get ( & self , idx : usize ) -> StackElement {
1303+ pub fn get ( & self , idx : usize ) -> StackElement < ' _ > {
13041304 match self . stack [ idx] {
13051305 InternalIndex ( i) => StackElement :: Index ( i) ,
13061306 InternalKey ( start, size) => {
@@ -1311,8 +1311,8 @@ impl Stack {
13111311 }
13121312 }
13131313
1314- /// Compares this stack with an array of StackElements .
1315- pub fn is_equal_to ( & self , rhs : & [ StackElement ] ) -> bool {
1314+ /// Compares this stack with an array of StackElement<'_>s .
1315+ pub fn is_equal_to ( & self , rhs : & [ StackElement < ' _ > ] ) -> bool {
13161316 if self . stack . len ( ) != rhs. len ( ) { return false ; }
13171317 for ( i, r) in rhs. iter ( ) . enumerate ( ) {
13181318 if self . get ( i) != * r { return false ; }
@@ -1322,7 +1322,7 @@ impl Stack {
13221322
13231323 /// Returns true if the bottom-most elements of this stack are the same as
13241324 /// the ones passed as parameter.
1325- pub fn starts_with ( & self , rhs : & [ StackElement ] ) -> bool {
1325+ pub fn starts_with ( & self , rhs : & [ StackElement < ' _ > ] ) -> bool {
13261326 if self . stack . len ( ) < rhs. len ( ) { return false ; }
13271327 for ( i, r) in rhs. iter ( ) . enumerate ( ) {
13281328 if self . get ( i) != * r { return false ; }
@@ -1332,7 +1332,7 @@ impl Stack {
13321332
13331333 /// Returns true if the top-most elements of this stack are the same as
13341334 /// the ones passed as parameter.
1335- pub fn ends_with ( & self , rhs : & [ StackElement ] ) -> bool {
1335+ pub fn ends_with ( & self , rhs : & [ StackElement < ' _ > ] ) -> bool {
13361336 if self . stack . len ( ) < rhs. len ( ) { return false ; }
13371337 let offset = self . stack . len ( ) - rhs. len ( ) ;
13381338 for ( i, r) in rhs. iter ( ) . enumerate ( ) {
@@ -1342,7 +1342,7 @@ impl Stack {
13421342 }
13431343
13441344 /// Returns the top-most element (if any).
1345- pub fn top ( & self ) -> Option < StackElement > {
1345+ pub fn top ( & self ) -> Option < StackElement < ' _ > > {
13461346 match self . stack . last ( ) {
13471347 None => None ,
13481348 Some ( & InternalIndex ( i) ) => Some ( StackElement :: Index ( i) ) ,
@@ -2115,7 +2115,7 @@ macro_rules! read_primitive {
21152115 }
21162116}
21172117
2118- impl :: Decoder for Decoder {
2118+ impl crate :: Decoder for Decoder {
21192119 type Error = DecoderError ;
21202120
21212121 fn read_nil ( & mut self ) -> DecodeResult < ( ) > {
@@ -2172,7 +2172,7 @@ impl ::Decoder for Decoder {
21722172 Err ( ExpectedError ( "single character string" . to_owned ( ) , s. to_string ( ) ) )
21732173 }
21742174
2175- fn read_str ( & mut self ) -> DecodeResult < Cow < str > > {
2175+ fn read_str ( & mut self ) -> DecodeResult < Cow < ' _ , str > > {
21762176 expect ! ( self . pop( ) , String ) . map ( Cow :: Owned )
21772177 }
21782178
@@ -2518,7 +2518,7 @@ impl<'a, 'b> fmt::Write for FormatShim<'a, 'b> {
25182518
25192519impl fmt:: Display for Json {
25202520 /// Encodes a json value into a string
2521- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2521+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
25222522 let mut shim = FormatShim { inner : f } ;
25232523 let mut encoder = Encoder :: new ( & mut shim) ;
25242524 match self . encode ( & mut encoder) {
@@ -2530,7 +2530,7 @@ impl fmt::Display for Json {
25302530
25312531impl < ' a > fmt:: Display for PrettyJson < ' a > {
25322532 /// Encodes a json value into a string
2533- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2533+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
25342534 let mut shim = FormatShim { inner : f } ;
25352535 let mut encoder = PrettyEncoder :: new ( & mut shim) ;
25362536 match self . inner . encode ( & mut encoder) {
@@ -2542,7 +2542,7 @@ impl<'a> fmt::Display for PrettyJson<'a> {
25422542
25432543impl < ' a , T : Encodable > fmt:: Display for AsJson < ' a , T > {
25442544 /// Encodes a json value into a string
2545- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2545+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
25462546 let mut shim = FormatShim { inner : f } ;
25472547 let mut encoder = Encoder :: new ( & mut shim) ;
25482548 match self . inner . encode ( & mut encoder) {
@@ -2562,7 +2562,7 @@ impl<'a, T> AsPrettyJson<'a, T> {
25622562
25632563impl < ' a , T : Encodable > fmt:: Display for AsPrettyJson < ' a , T > {
25642564 /// Encodes a json value into a string
2565- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2565+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
25662566 let mut shim = FormatShim { inner : f } ;
25672567 let mut encoder = PrettyEncoder :: new ( & mut shim) ;
25682568 if let Some ( n) = self . indent {
@@ -2587,7 +2587,7 @@ mod tests {
25872587 extern crate test;
25882588 use self :: Animal :: * ;
25892589 use self :: test:: Bencher ;
2590- use { Encodable , Decodable } ;
2590+ use crate :: { Encodable , Decodable } ;
25912591 use super :: Json :: * ;
25922592 use super :: ErrorCode :: * ;
25932593 use super :: ParserError :: * ;
@@ -3515,7 +3515,7 @@ mod tests {
35153515 #[ test]
35163516 fn test_hashmap_with_enum_key ( ) {
35173517 use std:: collections:: HashMap ;
3518- use json;
3518+ use crate :: json;
35193519 #[ derive( RustcEncodable , Eq , Hash , PartialEq , RustcDecodable , Debug ) ]
35203520 enum Enum {
35213521 Foo ,
0 commit comments