Skip to content

Commit ae2e9b1

Browse files
author
Tim
committed
Use edition = "2018"
1 parent aadd84f commit ae2e9b1

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description = """
55
"""
66
license = "MIT/Apache-2.0"
77
version = "1.2.2"
8+
edition = "2018"
89
keywords = ["macro", "error", "type", "enum"]
910
authors = ["Paul Colomiets <paul@colomiets.name>", "Colin Kiegel <kiegel@gmx.de>"]
1011
homepage = "http://github.com/tailhook/quick-error"

examples/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ quick_error! {
2828
}
2929

3030
fn parse_file() -> Result<u64, Error> {
31-
let fname = try!(env::args().skip(1).next().ok_or(Error::NoFileName));
31+
let fname = env::args().skip(1).next().ok_or(Error::NoFileName)?;
3232
let fname = Path::new(&fname);
33-
let mut file = try!(File::open(fname).context(fname));
33+
let mut file = File::open(fname).context(fname)?;
3434
let mut buf = String::new();
35-
try!(file.read_to_string(&mut buf).context(fname));
35+
file.read_to_string(&mut buf).context(fname)?;
3636
Ok(try!(buf.parse().context(fname)))
3737
}
3838

src/lib.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@
228228
//! }
229229
//!
230230
//! fn openfile(path: &Path) -> Result<(), Error> {
231-
//! try!(File::open(path).context(path));
231+
//! File::open(path).context(path)?;
232232
//!
233233
//! // If we didn't have context, the line above would be written as;
234234
//! //
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))?;
237237
//!
238238
//! Ok(())
239239
//! }
@@ -364,11 +364,11 @@ macro_rules! quick_error {
364364
$(#[$meta])*
365365
$($strdef)* $strname ( $internal );
366366

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
370370
{
371-
::std::fmt::Display::fmt(&self.0, f)
371+
::core::fmt::Display::fmt(&self.0, f)
372372
}
373373
}
374374

@@ -643,9 +643,9 @@ macro_rules! quick_error {
643643
#[allow(renamed_and_removed_lints)]
644644
#[allow(unused_doc_comment)]
645645
#[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
649649
{
650650
match *self {
651651
$(
@@ -712,17 +712,17 @@ macro_rules! quick_error {
712712
(FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt
713713
{ display($self_:tt) -> ($( $exprs:tt )*) $( $tail:tt )*}
714714
) => {
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 )*) }
716716
};
717717
(FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt
718718
{ display($pattern:expr) $( $tail:tt )*}
719719
) => {
720-
|_, f: &mut ::std::fmt::Formatter| { write!(f, $pattern) }
720+
|_, f: &mut ::core::fmt::Formatter| { write!(f, $pattern) }
721721
};
722722
(FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt
723723
{ display($pattern:expr, $( $exprs:tt )*) $( $tail:tt )*}
724724
) => {
725-
|_, f: &mut ::std::fmt::Formatter| { write!(f, $pattern, $( $exprs )*) }
725+
|_, f: &mut ::core::fmt::Formatter| { write!(f, $pattern, $( $exprs )*) }
726726
};
727727
(FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt
728728
{ $t:tt $( $tail:tt )*}
@@ -734,7 +734,7 @@ macro_rules! quick_error {
734734
(FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt
735735
{ }
736736
) => {
737-
|self_: &$name, f: &mut ::std::fmt::Formatter| {
737+
|self_: &$name, f: &mut ::core::fmt::Formatter| {
738738
write!(f, "{}", ::std::error::Error::description(self_))
739739
}
740740
};
@@ -1255,7 +1255,7 @@ mod test {
12551255
#[test]
12561256
fn parse_float_error() {
12571257
fn parse_float(s: &str) -> Result<f32, ContextErr> {
1258-
Ok(try!(s.parse().context(s)))
1258+
Ok(s.parse().context(s)?)
12591259
}
12601260
assert_eq!(format!("{}", parse_float("12ab").unwrap_err()),
12611261
r#"Float error "12ab": invalid float literal"#);
@@ -1264,7 +1264,7 @@ mod test {
12641264
#[test]
12651265
fn parse_int_error() {
12661266
fn parse_int(s: &str) -> Result<i32, ContextErr> {
1267-
Ok(try!(s.parse().context(s)))
1267+
Ok(s.parse().context(s)?)
12681268
}
12691269
assert_eq!(format!("{}", parse_int("12.5").unwrap_err()),
12701270
r#"Int error "12.5": invalid digit found in string"#);
@@ -1285,7 +1285,7 @@ mod test {
12851285
fn parse_utf<P: AsRef<Path>>(s: &[u8], p: P)
12861286
-> Result<(), ContextErr>
12871287
{
1288-
try!(::std::str::from_utf8(s).context(p));
1288+
::std::str::from_utf8(s).context(p)?;
12891289
Ok(())
12901290
}
12911291
let etext = parse_utf(b"a\x80\x80", "/etc").unwrap_err().to_string();

0 commit comments

Comments
 (0)