diff --git a/submodules/rust-phf b/submodules/rust-phf index 3491ce3a..d752241b 160000 --- a/submodules/rust-phf +++ b/submodules/rust-phf @@ -1 +1 @@ -Subproject commit 3491ce3add5a93db2decf61d160daf3424f6cf3d +Subproject commit d752241bf21e60575bf89f24c4359b34aef20d9c diff --git a/tests.rs b/tests.rs index 29eb8dff..f4ff33be 100644 --- a/tests.rs +++ b/tests.rs @@ -41,18 +41,18 @@ fn test_pool() { let (stream1, stream2) = DuplexStream::<(), ()>::new(); let pool1 = pool.clone(); - let mut fut1 = do Future::spawn { + let mut fut1 = Future::spawn(proc() { let _conn = pool1.get_connection(); stream1.send(()); stream1.recv(); - }; + }); let pool2 = pool.clone(); - let mut fut2 = do Future::spawn { + let mut fut2 = Future::spawn(proc() { let _conn = pool2.get_connection(); stream2.send(()); stream2.recv(); - }; + }); fut1.get(); fut2.get(); @@ -581,23 +581,23 @@ fn test_f64_nan_param() { #[should_fail] fn test_wrong_param_type() { let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl); - conn.try_execute("SELECT $1::VARCHAR", [&1i32 as &ToSql]); + let _ = conn.try_execute("SELECT $1::VARCHAR", [&1i32 as &ToSql]); } #[test] #[should_fail] fn test_too_few_params() { let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl); - conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql]); + let _ = conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql]); } #[test] #[should_fail] fn test_too_many_params() { let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl); - conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql, - &2i32 as &ToSql, - &3i32 as &ToSql]); + let _ = conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql, + &2i32 as &ToSql, + &3i32 as &ToSql]); } #[test] @@ -695,11 +695,11 @@ fn test_cancel_query() { let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl); let cancel_data = conn.cancel_data(); - do spawn { + spawn(proc() { timer::sleep(500); assert!(super::cancel_query("postgres://postgres@localhost", &NoSsl, cancel_data).is_ok()); - } + }); match conn.try_execute("SELECT pg_sleep(10)", []) { Err(PostgresDbError { code: QueryCanceled, .. }) => {} diff --git a/types/mod.rs b/types/mod.rs index 5646238f..e1c84bc4 100644 --- a/types/mod.rs +++ b/types/mod.rs @@ -545,15 +545,15 @@ macro_rules! to_range_impl( if self.is_empty() { tag |= RANGE_EMPTY; } else { - match *self.lower() { + match self.lower() { None => tag |= RANGE_LOWER_UNBOUNDED, - Some(RangeBound { type_: Inclusive, .. }) => + Some(&RangeBound { type_: Inclusive, .. }) => tag |= RANGE_LOWER_INCLUSIVE, _ => {} } - match *self.upper() { + match self.upper() { None => tag |= RANGE_UPPER_UNBOUNDED, - Some(RangeBound { type_: Inclusive, .. }) => + Some(&RangeBound { type_: Inclusive, .. }) => tag |= RANGE_UPPER_INCLUSIVE, _ => {} } @@ -561,8 +561,8 @@ macro_rules! to_range_impl( buf.write_i8(tag); - match *self.lower() { - Some(ref bound) => { + match self.lower() { + Some(bound) => { let mut inner_buf = MemWriter::new(); bound.value.raw_to_sql(&mut inner_buf); let inner_buf = inner_buf.unwrap(); @@ -571,8 +571,8 @@ macro_rules! to_range_impl( } None => {} } - match *self.upper() { - Some(ref bound) => { + match self.upper() { + Some(bound) => { let mut inner_buf = MemWriter::new(); bound.value.raw_to_sql(&mut inner_buf); let inner_buf = inner_buf.unwrap(); diff --git a/types/range.rs b/types/range.rs index 551a1a3d..88184b18 100644 --- a/types/range.rs +++ b/types/range.rs @@ -207,15 +207,15 @@ impl RangeBound { } } -struct OptBound<'a, S, T>(&'a Option>); +struct OptBound<'a, S, T>(Option<&'a RangeBound>); impl<'a, S: BoundSided, T: Ord> Ord for OptBound<'a, S, T> { fn lt(&self, other: &OptBound<'a, S, T>) -> bool { match (*self, *other) { - (OptBound(&None), OptBound(&None)) => false, - (OptBound(&None), _) => BoundSided::side(None::) == Lower, - (_, OptBound(&None)) => BoundSided::side(None::) == Upper, - (OptBound(&Some(ref a)), OptBound(&Some(ref b))) => a < b + (OptBound(None), OptBound(None)) => false, + (OptBound(None), _) => BoundSided::side(None::) == Lower, + (_, OptBound(None)) => BoundSided::side(None::) == Upper, + (OptBound(Some(a)), OptBound(Some(b))) => a < b } } } @@ -267,18 +267,18 @@ impl Range { } /// Returns the lower bound if it exists. - pub fn lower<'a>(&'a self) -> &'a Option> { + pub fn lower<'a>(&'a self) -> Option<&'a RangeBound> { match *self { - Empty => &None, - Normal(ref lower, _) => lower + Normal(Some(ref lower), _) => Some(lower), + _ => None } } /// Returns the upper bound if it exists. - pub fn upper<'a>(&'a self) -> &'a Option> { + pub fn upper<'a>(&'a self) -> Option<&'a RangeBound> { match *self { - Empty => &None, - Normal(_, ref upper) => upper + Normal(_, Some(ref upper)) => Some(upper), + _ => None } } @@ -320,7 +320,7 @@ impl Range { let OptBound(upper) = cmp::min(OptBound(self.upper()), OptBound(other.upper())); - Range::new(lower.clone(), upper.clone()) + Range::new(lower.map(|v| v.clone()), upper.map(|v| v.clone())) } } @@ -467,7 +467,8 @@ mod test { assert_eq!(r1, (range!('(', ')')).intersect(&r1)); let r2 = range!('(' 10i32, ')'); - let exp = Range::new(r2.lower().clone(), r1.upper().clone()); + let exp = Range::new(r2.lower().map(|v| v.clone()), + r1.upper().map(|v| v.clone())); assert_eq!(exp, r1.intersect(&r2)); assert_eq!(exp, r2.intersect(&r1));