@@ -201,7 +201,7 @@ use std::string;
201
201
use std:: { char, f64, fmt, str} ;
202
202
use std;
203
203
204
- use Encodable ;
204
+ use crate :: Encodable ;
205
205
206
206
/// Represents a json value
207
207
#[ derive( Clone , PartialEq , PartialOrd , Debug ) ]
@@ -221,8 +221,8 @@ pub type Object = BTreeMap<string::String, Json>;
221
221
222
222
pub struct PrettyJson < ' a > { inner : & ' a Json }
223
223
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 > }
226
226
227
227
/// The errors that can arise while parsing a JSON stream.
228
228
#[ derive( Clone , Copy , PartialEq , Debug ) ]
@@ -295,18 +295,18 @@ pub fn error_str(error: ErrorCode) -> &'static str {
295
295
}
296
296
297
297
/// 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 > {
299
299
let json = match from_str ( s) {
300
300
Ok ( x) => x,
301
301
Err ( e) => return Err ( ParseError ( e) )
302
302
} ;
303
303
304
304
let mut decoder = Decoder :: new ( json) ;
305
- :: Decodable :: decode ( & mut decoder)
305
+ crate :: Decodable :: decode ( & mut decoder)
306
306
}
307
307
308
308
/// 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 > {
310
310
let mut s = String :: new ( ) ;
311
311
{
312
312
let mut encoder = Encoder :: new ( & mut s) ;
@@ -316,7 +316,7 @@ pub fn encode<T: ::Encodable>(object: &T) -> Result<string::String, EncoderError
316
316
}
317
317
318
318
impl fmt:: Display for ErrorCode {
319
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
319
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
320
320
error_str ( * self ) . fmt ( f)
321
321
}
322
322
}
@@ -326,14 +326,14 @@ fn io_error_to_error(io: io::Error) -> ParserError {
326
326
}
327
327
328
328
impl fmt:: Display for ParserError {
329
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
329
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
330
330
// FIXME this should be a nicer error
331
331
fmt:: Debug :: fmt ( self , f)
332
332
}
333
333
}
334
334
335
335
impl fmt:: Display for DecoderError {
336
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
336
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
337
337
// FIXME this should be a nicer error
338
338
fmt:: Debug :: fmt ( self , f)
339
339
}
@@ -344,7 +344,7 @@ impl std::error::Error for DecoderError {
344
344
}
345
345
346
346
impl fmt:: Display for EncoderError {
347
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
347
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
348
348
// FIXME this should be a nicer error
349
349
fmt:: Debug :: fmt ( self , f)
350
350
}
@@ -477,7 +477,7 @@ macro_rules! emit_enquoted_if_mapkey {
477
477
} )
478
478
}
479
479
480
- impl < ' a > :: Encoder for Encoder < ' a > {
480
+ impl < ' a > crate :: Encoder for Encoder < ' a > {
481
481
type Error = EncoderError ;
482
482
483
483
fn emit_unit ( & mut self ) -> EncodeResult {
@@ -727,7 +727,7 @@ impl<'a> PrettyEncoder<'a> {
727
727
}
728
728
}
729
729
730
- impl < ' a > :: Encoder for PrettyEncoder < ' a > {
730
+ impl < ' a > crate :: Encoder for PrettyEncoder < ' a > {
731
731
type Error = EncoderError ;
732
732
733
733
fn emit_unit ( & mut self ) -> EncodeResult {
@@ -997,7 +997,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> {
997
997
}
998
998
999
999
impl 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 > {
1001
1001
match * self {
1002
1002
Json :: I64 ( v) => v. encode ( e) ,
1003
1003
Json :: U64 ( v) => v. encode ( e) ,
@@ -1013,20 +1013,20 @@ impl Encodable for Json {
1013
1013
1014
1014
/// Create an `AsJson` wrapper which can be used to print a value as JSON
1015
1015
/// 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 > {
1017
1017
AsJson { inner : t }
1018
1018
}
1019
1019
1020
1020
/// Create an `AsPrettyJson` wrapper which can be used to print a value as JSON
1021
1021
/// 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 > {
1023
1023
AsPrettyJson { inner : t, indent : None }
1024
1024
}
1025
1025
1026
1026
impl Json {
1027
1027
/// Borrow this json object as a pretty object to generate a pretty
1028
1028
/// representation for it via `Display`.
1029
- pub fn pretty ( & self ) -> PrettyJson {
1029
+ pub fn pretty ( & self ) -> PrettyJson < ' _ > {
1030
1030
PrettyJson { inner : self }
1031
1031
}
1032
1032
@@ -1300,7 +1300,7 @@ impl Stack {
1300
1300
/// Provides access to the StackElement at a given index.
1301
1301
/// lower indices are at the bottom of the stack while higher indices are
1302
1302
/// at the top.
1303
- pub fn get ( & self , idx : usize ) -> StackElement {
1303
+ pub fn get ( & self , idx : usize ) -> StackElement < ' _ > {
1304
1304
match self . stack [ idx] {
1305
1305
InternalIndex ( i) => StackElement :: Index ( i) ,
1306
1306
InternalKey ( start, size) => {
@@ -1311,8 +1311,8 @@ impl Stack {
1311
1311
}
1312
1312
}
1313
1313
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 {
1316
1316
if self . stack . len ( ) != rhs. len ( ) { return false ; }
1317
1317
for ( i, r) in rhs. iter ( ) . enumerate ( ) {
1318
1318
if self . get ( i) != * r { return false ; }
@@ -1322,7 +1322,7 @@ impl Stack {
1322
1322
1323
1323
/// Returns true if the bottom-most elements of this stack are the same as
1324
1324
/// the ones passed as parameter.
1325
- pub fn starts_with ( & self , rhs : & [ StackElement ] ) -> bool {
1325
+ pub fn starts_with ( & self , rhs : & [ StackElement < ' _ > ] ) -> bool {
1326
1326
if self . stack . len ( ) < rhs. len ( ) { return false ; }
1327
1327
for ( i, r) in rhs. iter ( ) . enumerate ( ) {
1328
1328
if self . get ( i) != * r { return false ; }
@@ -1332,7 +1332,7 @@ impl Stack {
1332
1332
1333
1333
/// Returns true if the top-most elements of this stack are the same as
1334
1334
/// the ones passed as parameter.
1335
- pub fn ends_with ( & self , rhs : & [ StackElement ] ) -> bool {
1335
+ pub fn ends_with ( & self , rhs : & [ StackElement < ' _ > ] ) -> bool {
1336
1336
if self . stack . len ( ) < rhs. len ( ) { return false ; }
1337
1337
let offset = self . stack . len ( ) - rhs. len ( ) ;
1338
1338
for ( i, r) in rhs. iter ( ) . enumerate ( ) {
@@ -1342,7 +1342,7 @@ impl Stack {
1342
1342
}
1343
1343
1344
1344
/// Returns the top-most element (if any).
1345
- pub fn top ( & self ) -> Option < StackElement > {
1345
+ pub fn top ( & self ) -> Option < StackElement < ' _ > > {
1346
1346
match self . stack . last ( ) {
1347
1347
None => None ,
1348
1348
Some ( & InternalIndex ( i) ) => Some ( StackElement :: Index ( i) ) ,
@@ -2115,7 +2115,7 @@ macro_rules! read_primitive {
2115
2115
}
2116
2116
}
2117
2117
2118
- impl :: Decoder for Decoder {
2118
+ impl crate :: Decoder for Decoder {
2119
2119
type Error = DecoderError ;
2120
2120
2121
2121
fn read_nil ( & mut self ) -> DecodeResult < ( ) > {
@@ -2172,7 +2172,7 @@ impl ::Decoder for Decoder {
2172
2172
Err ( ExpectedError ( "single character string" . to_owned ( ) , s. to_string ( ) ) )
2173
2173
}
2174
2174
2175
- fn read_str ( & mut self ) -> DecodeResult < Cow < str > > {
2175
+ fn read_str ( & mut self ) -> DecodeResult < Cow < ' _ , str > > {
2176
2176
expect ! ( self . pop( ) , String ) . map ( Cow :: Owned )
2177
2177
}
2178
2178
@@ -2518,7 +2518,7 @@ impl<'a, 'b> fmt::Write for FormatShim<'a, 'b> {
2518
2518
2519
2519
impl fmt:: Display for Json {
2520
2520
/// 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 {
2522
2522
let mut shim = FormatShim { inner : f } ;
2523
2523
let mut encoder = Encoder :: new ( & mut shim) ;
2524
2524
match self . encode ( & mut encoder) {
@@ -2530,7 +2530,7 @@ impl fmt::Display for Json {
2530
2530
2531
2531
impl < ' a > fmt:: Display for PrettyJson < ' a > {
2532
2532
/// 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 {
2534
2534
let mut shim = FormatShim { inner : f } ;
2535
2535
let mut encoder = PrettyEncoder :: new ( & mut shim) ;
2536
2536
match self . inner . encode ( & mut encoder) {
@@ -2542,7 +2542,7 @@ impl<'a> fmt::Display for PrettyJson<'a> {
2542
2542
2543
2543
impl < ' a , T : Encodable > fmt:: Display for AsJson < ' a , T > {
2544
2544
/// 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 {
2546
2546
let mut shim = FormatShim { inner : f } ;
2547
2547
let mut encoder = Encoder :: new ( & mut shim) ;
2548
2548
match self . inner . encode ( & mut encoder) {
@@ -2562,7 +2562,7 @@ impl<'a, T> AsPrettyJson<'a, T> {
2562
2562
2563
2563
impl < ' a , T : Encodable > fmt:: Display for AsPrettyJson < ' a , T > {
2564
2564
/// 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 {
2566
2566
let mut shim = FormatShim { inner : f } ;
2567
2567
let mut encoder = PrettyEncoder :: new ( & mut shim) ;
2568
2568
if let Some ( n) = self . indent {
@@ -2587,7 +2587,7 @@ mod tests {
2587
2587
extern crate test;
2588
2588
use self :: Animal :: * ;
2589
2589
use self :: test:: Bencher ;
2590
- use { Encodable , Decodable } ;
2590
+ use crate :: { Encodable , Decodable } ;
2591
2591
use super :: Json :: * ;
2592
2592
use super :: ErrorCode :: * ;
2593
2593
use super :: ParserError :: * ;
@@ -3515,7 +3515,7 @@ mod tests {
3515
3515
#[ test]
3516
3516
fn test_hashmap_with_enum_key ( ) {
3517
3517
use std:: collections:: HashMap ;
3518
- use json;
3518
+ use crate :: json;
3519
3519
#[ derive( RustcEncodable , Eq , Hash , PartialEq , RustcDecodable , Debug ) ]
3520
3520
enum Enum {
3521
3521
Foo ,
0 commit comments