Skip to content

Commit 9d547b5

Browse files
committed
Replace all try! with ?
1 parent c536e49 commit 9d547b5

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/impls.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ impl<T> FromSql for Range<T> where T: PartialOrd+Normalizable+FromSql {
1111
_ => panic!("unexpected type {:?}", ty)
1212
};
1313

14-
match try!(types::range_from_sql(raw)) {
14+
match types::range_from_sql(raw)? {
1515
types::Range::Empty => Ok(Range::empty()),
1616
types::Range::Nonempty(lower, upper) => {
17-
let lower = try!(bound_from_sql(lower, element_type));
18-
let upper = try!(bound_from_sql(upper, element_type));
17+
let lower = bound_from_sql(lower, element_type)?;
18+
let upper = bound_from_sql(upper, element_type)?;
1919
Ok(Range::new(lower, upper))
2020
}
2121
}
@@ -36,15 +36,15 @@ fn bound_from_sql<T, S>(bound: types::RangeBound<Option<&[u8]>>, ty: &Type) -> R
3636
match bound {
3737
types::RangeBound::Exclusive(value) => {
3838
let value = match value {
39-
Some(value) => try!(T::from_sql(ty, value)),
40-
None => try!(T::from_sql_null(ty)),
39+
Some(value) => T::from_sql(ty, value)?,
40+
None => T::from_sql_null(ty)?,
4141
};
4242
Ok(Some(RangeBound::new(value, BoundType::Exclusive)))
4343
},
4444
types::RangeBound::Inclusive(value) => {
4545
let value = match value {
46-
Some(value) => try!(T::from_sql(ty, value)),
47-
None => try!(T::from_sql_null(ty)),
46+
Some(value) => T::from_sql(ty, value)?,
47+
None => T::from_sql_null(ty)?,
4848
};
4949
Ok(Some(RangeBound::new(value, BoundType::Inclusive)))
5050
},
@@ -62,9 +62,9 @@ impl<T> ToSql for Range<T> where T: PartialOrd+Normalizable+ToSql {
6262
if self.is_empty() {
6363
types::empty_range_to_sql(buf);
6464
} else {
65-
try!(types::range_to_sql(|buf| bound_to_sql(self.lower(), element_type, buf),
65+
types::range_to_sql(|buf| bound_to_sql(self.lower(), element_type, buf),
6666
|buf| bound_to_sql(self.upper(), element_type, buf),
67-
buf));
67+
buf)?;
6868
}
6969

7070
Ok(IsNull::No)
@@ -86,7 +86,7 @@ fn bound_to_sql<S, T>(bound: Option<&RangeBound<S, T>>, ty: &Type, buf: &mut Vec
8686
{
8787
match bound {
8888
Some(bound) => {
89-
let null = match try!(bound.value.to_sql(ty, buf)) {
89+
let null = match bound.value.to_sql(ty, buf)? {
9090
IsNull::Yes => protocol::IsNull::Yes,
9191
IsNull::No => protocol::IsNull::No,
9292
};

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,10 @@ impl<T> fmt::Display for Range<T> where T: fmt::Display {
348348
Empty => write!(fmt, "empty"),
349349
Normal(ref lower, ref upper) => {
350350
match *lower {
351-
Some(ref bound) => try!(write!(fmt, "{}", bound)),
352-
None => try!(write!(fmt, "(")),
351+
Some(ref bound) => write!(fmt, "{}", bound)?,
352+
None => write!(fmt, "(")?,
353353
}
354-
try!(write!(fmt, ","));
354+
write!(fmt, ",")?;
355355
match *upper {
356356
Some(ref bound) => write!(fmt, "{}", bound),
357357
None => write!(fmt, ")"),

0 commit comments

Comments
 (0)