Some more if let conversion

This commit is contained in:
Steven Fackler 2014-10-25 17:58:46 -07:00
parent c63a7f9a15
commit a480ec1cfb
3 changed files with 11 additions and 16 deletions

View File

@ -629,9 +629,8 @@ impl InnerPostgresConnection {
fn set_type_names<'a, I>(&mut self, mut it: I) -> PostgresResult<()>
where I: Iterator<&'a mut PostgresType> {
for ty in it {
match *ty {
PgUnknownType { oid, ref mut name } => *name = try!(self.get_type_name(oid)),
_ => {}
if let &PgUnknownType { oid, ref mut name } = ty {
*name = try!(self.get_type_name(oid));
}
}

View File

@ -243,9 +243,8 @@ impl<W: Writer> WriteMessage for W {
}
}
match ident {
Some(ident) => try!(self.write_u8(ident)),
None => ()
if let Some(ident) = ident {
try!(self.write_u8(ident));
}
let buf = buf.unwrap();

View File

@ -337,17 +337,14 @@ impl<T> Range<T> where T: PartialOrd+Normalizable{
let lower = lower.map(Normalizable::normalize);
let upper = upper.map(Normalizable::normalize);
match (&lower, &upper) {
(&Some(ref lower), &Some(ref upper)) => {
let empty = match (lower.type_, upper.type_) {
(Inclusive, Inclusive) => lower.value > upper.value,
_ => lower.value >= upper.value
};
if empty {
return Range { inner: Empty };
}
if let (&Some(ref lower), &Some(ref upper)) = (&lower, &upper) {
let empty = match (lower.type_, upper.type_) {
(Inclusive, Inclusive) => lower.value > upper.value,
_ => lower.value >= upper.value
};
if empty {
return Range { inner: Empty };
}
_ => {}
}
Range { inner: Normal(lower, upper) }