228
228
//! }
229
229
//!
230
230
//! fn openfile(path: &Path) -> Result<(), Error> {
231
- //! try!( File::open(path).context(path)) ;
231
+ //! File::open(path).context(path)? ;
232
232
//!
233
233
//! // If we didn't have context, the line above would be written as;
234
234
//! //
235
- //! // try!( File::open(path)
236
- //! // .map_err(|err| Error::File(path.to_path_buf(), err))) ;
235
+ //! // File::open(path)
236
+ //! // .map_err(|err| Error::File(path.to_path_buf(), err))? ;
237
237
//!
238
238
//! Ok(())
239
239
//! }
@@ -364,11 +364,11 @@ macro_rules! quick_error {
364
364
$( #[ $meta] ) *
365
365
$( $strdef) * $strname ( $internal ) ;
366
366
367
- impl :: std :: fmt:: Display for $strname {
368
- fn fmt( & self , f: & mut :: std :: fmt:: Formatter )
369
- -> :: std :: fmt:: Result
367
+ impl :: core :: fmt:: Display for $strname {
368
+ fn fmt( & self , f: & mut :: core :: fmt:: Formatter )
369
+ -> :: core :: fmt:: Result
370
370
{
371
- :: std :: fmt:: Display :: fmt( & self . 0 , f)
371
+ :: core :: fmt:: Display :: fmt( & self . 0 , f)
372
372
}
373
373
}
374
374
@@ -643,9 +643,9 @@ macro_rules! quick_error {
643
643
#[ allow( renamed_and_removed_lints) ]
644
644
#[ allow( unused_doc_comment) ]
645
645
#[ allow( unused_doc_comments) ]
646
- impl :: std :: fmt:: Display for $name {
647
- fn fmt( & self , fmt: & mut :: std :: fmt:: Formatter )
648
- -> :: std :: fmt:: Result
646
+ impl :: core :: fmt:: Display for $name {
647
+ fn fmt( & self , fmt: & mut :: core :: fmt:: Formatter )
648
+ -> :: core :: fmt:: Result
649
649
{
650
650
match * self {
651
651
$(
@@ -712,17 +712,17 @@ macro_rules! quick_error {
712
712
( FIND_DISPLAY_IMPL $name: ident $item: ident: $imode: tt
713
713
{ display( $self_: tt) -> ( $( $exprs: tt ) * ) $( $tail: tt ) * }
714
714
) => {
715
- |quick_error!( IDENT $self_) : & $name, f: & mut :: std :: fmt:: Formatter | { write!( f, $( $exprs ) * ) }
715
+ |quick_error!( IDENT $self_) : & $name, f: & mut :: core :: fmt:: Formatter | { write!( f, $( $exprs ) * ) }
716
716
} ;
717
717
( FIND_DISPLAY_IMPL $name: ident $item: ident: $imode: tt
718
718
{ display( $pattern: expr) $( $tail: tt ) * }
719
719
) => {
720
- |_, f: & mut :: std :: fmt:: Formatter | { write!( f, $pattern) }
720
+ |_, f: & mut :: core :: fmt:: Formatter | { write!( f, $pattern) }
721
721
} ;
722
722
( FIND_DISPLAY_IMPL $name: ident $item: ident: $imode: tt
723
723
{ display( $pattern: expr, $( $exprs: tt ) * ) $( $tail: tt ) * }
724
724
) => {
725
- |_, f: & mut :: std :: fmt:: Formatter | { write!( f, $pattern, $( $exprs ) * ) }
725
+ |_, f: & mut :: core :: fmt:: Formatter | { write!( f, $pattern, $( $exprs ) * ) }
726
726
} ;
727
727
( FIND_DISPLAY_IMPL $name: ident $item: ident: $imode: tt
728
728
{ $t: tt $( $tail: tt ) * }
@@ -734,7 +734,7 @@ macro_rules! quick_error {
734
734
( FIND_DISPLAY_IMPL $name: ident $item: ident: $imode: tt
735
735
{ }
736
736
) => {
737
- |self_: & $name, f: & mut :: std :: fmt:: Formatter | {
737
+ |self_: & $name, f: & mut :: core :: fmt:: Formatter | {
738
738
write!( f, "{}" , :: std:: error:: Error :: description( self_) )
739
739
}
740
740
} ;
@@ -1255,7 +1255,7 @@ mod test {
1255
1255
#[ test]
1256
1256
fn parse_float_error ( ) {
1257
1257
fn parse_float ( s : & str ) -> Result < f32 , ContextErr > {
1258
- Ok ( try! ( s. parse ( ) . context ( s) ) )
1258
+ Ok ( s. parse ( ) . context ( s) ? )
1259
1259
}
1260
1260
assert_eq ! ( format!( "{}" , parse_float( "12ab" ) . unwrap_err( ) ) ,
1261
1261
r#"Float error "12ab": invalid float literal"# ) ;
@@ -1264,7 +1264,7 @@ mod test {
1264
1264
#[ test]
1265
1265
fn parse_int_error ( ) {
1266
1266
fn parse_int ( s : & str ) -> Result < i32 , ContextErr > {
1267
- Ok ( try! ( s. parse ( ) . context ( s) ) )
1267
+ Ok ( s. parse ( ) . context ( s) ? )
1268
1268
}
1269
1269
assert_eq ! ( format!( "{}" , parse_int( "12.5" ) . unwrap_err( ) ) ,
1270
1270
r#"Int error "12.5": invalid digit found in string"# ) ;
@@ -1285,7 +1285,7 @@ mod test {
1285
1285
fn parse_utf < P : AsRef < Path > > ( s : & [ u8 ] , p : P )
1286
1286
-> Result < ( ) , ContextErr >
1287
1287
{
1288
- try! ( :: std:: str:: from_utf8 ( s) . context ( p) ) ;
1288
+ :: std:: str:: from_utf8 ( s) . context ( p) ? ;
1289
1289
Ok ( ( ) )
1290
1290
}
1291
1291
let etext = parse_utf ( b"a\x80 \x80 " , "/etc" ) . unwrap_err ( ) . to_string ( ) ;
0 commit comments