Skip to content

Commit 16d9f5f

Browse files
bors[bot]phimuemue
andauthored
Merge #392
392: Use `?` instead of deprecated `try!` r=jswrenn a=phimuemue I suggest using `?` instead of the deprecated `try!` macro. Rust 1.40 warned: use of deprecated item 'try': use the `?` operator instead. Rust 1.13 introduced `?`, we require Rust 1.24 as minimal version. Co-authored-by: philipp <[email protected]>
2 parents adb66f1 + fabdd8b commit 16d9f5f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

examples/iris.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl FromStr for Iris {
4444

4545
// using Iterator::by_ref()
4646
for (index, part) in parts.by_ref().take(4).enumerate() {
47-
iris.data[index] = try!(part.parse::<f32>());
47+
iris.data[index] = part.parse::<f32>()?;
4848
}
4949
if let Some(name) = parts.next() {
5050
iris.name = name.into();

src/format.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ impl<'a, I, F> fmt::Display for FormatWith<'a, I, F>
5858
};
5959

6060
if let Some(fst) = iter.next() {
61-
try!(format(fst, &mut |disp: &fmt::Display| disp.fmt(f)));
61+
format(fst, &mut |disp: &fmt::Display| disp.fmt(f))?;
6262
for elt in iter {
6363
if self.sep.len() > 0 {
6464

65-
try!(f.write_str(self.sep));
65+
f.write_str(self.sep)?;
6666
}
67-
try!(format(elt, &mut |disp: &fmt::Display| disp.fmt(f)));
67+
format(elt, &mut |disp: &fmt::Display| disp.fmt(f))?;
6868
}
6969
}
7070
Ok(())
@@ -83,12 +83,12 @@ impl<'a, I> Format<'a, I>
8383
};
8484

8585
if let Some(fst) = iter.next() {
86-
try!(cb(&fst, f));
86+
cb(&fst, f)?;
8787
for elt in iter {
8888
if self.sep.len() > 0 {
89-
try!(f.write_str(self.sep));
89+
f.write_str(self.sep)?;
9090
}
91-
try!(cb(&elt, f));
91+
cb(&elt, f)?;
9292
}
9393
}
9494
Ok(())

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,7 @@ pub trait Itertools : Iterator {
18801880
II: Iterator<Item = T>,
18811881
FF: FnMut(T, T) -> T
18821882
{
1883-
let mut x = try!(inner0(it, f));
1883+
let mut x = inner0(it, f)?;
18841884
for height in 0..stop {
18851885
// Try to get another tree the same size with which to combine it,
18861886
// creating a new tree that's twice as big for next time around.

0 commit comments

Comments
 (0)