Skip to content

Commit 2c55ae5

Browse files
committed
Update for API changes
Lots of stuff this time!
1 parent 8323169 commit 2c55ae5

4 files changed

Lines changed: 34 additions & 33 deletions

File tree

submodules/rust-phf

Submodule rust-phf updated from 3491ce3 to d752241

tests.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ fn test_pool() {
4141
let (stream1, stream2) = DuplexStream::<(), ()>::new();
4242

4343
let pool1 = pool.clone();
44-
let mut fut1 = do Future::spawn {
44+
let mut fut1 = Future::spawn(proc() {
4545
let _conn = pool1.get_connection();
4646
stream1.send(());
4747
stream1.recv();
48-
};
48+
});
4949

5050
let pool2 = pool.clone();
51-
let mut fut2 = do Future::spawn {
51+
let mut fut2 = Future::spawn(proc() {
5252
let _conn = pool2.get_connection();
5353
stream2.send(());
5454
stream2.recv();
55-
};
55+
});
5656

5757
fut1.get();
5858
fut2.get();
@@ -581,23 +581,23 @@ fn test_f64_nan_param() {
581581
#[should_fail]
582582
fn test_wrong_param_type() {
583583
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
584-
conn.try_execute("SELECT $1::VARCHAR", [&1i32 as &ToSql]);
584+
let _ = conn.try_execute("SELECT $1::VARCHAR", [&1i32 as &ToSql]);
585585
}
586586

587587
#[test]
588588
#[should_fail]
589589
fn test_too_few_params() {
590590
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
591-
conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql]);
591+
let _ = conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql]);
592592
}
593593

594594
#[test]
595595
#[should_fail]
596596
fn test_too_many_params() {
597597
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
598-
conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql,
599-
&2i32 as &ToSql,
600-
&3i32 as &ToSql]);
598+
let _ = conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql,
599+
&2i32 as &ToSql,
600+
&3i32 as &ToSql]);
601601
}
602602

603603
#[test]
@@ -695,11 +695,11 @@ fn test_cancel_query() {
695695
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
696696
let cancel_data = conn.cancel_data();
697697

698-
do spawn {
698+
spawn(proc() {
699699
timer::sleep(500);
700700
assert!(super::cancel_query("postgres://postgres@localhost", &NoSsl,
701701
cancel_data).is_ok());
702-
}
702+
});
703703

704704
match conn.try_execute("SELECT pg_sleep(10)", []) {
705705
Err(PostgresDbError { code: QueryCanceled, .. }) => {}

types/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -545,24 +545,24 @@ macro_rules! to_range_impl(
545545
if self.is_empty() {
546546
tag |= RANGE_EMPTY;
547547
} else {
548-
match *self.lower() {
548+
match self.lower() {
549549
None => tag |= RANGE_LOWER_UNBOUNDED,
550-
Some(RangeBound { type_: Inclusive, .. }) =>
550+
Some(&RangeBound { type_: Inclusive, .. }) =>
551551
tag |= RANGE_LOWER_INCLUSIVE,
552552
_ => {}
553553
}
554-
match *self.upper() {
554+
match self.upper() {
555555
None => tag |= RANGE_UPPER_UNBOUNDED,
556-
Some(RangeBound { type_: Inclusive, .. }) =>
556+
Some(&RangeBound { type_: Inclusive, .. }) =>
557557
tag |= RANGE_UPPER_INCLUSIVE,
558558
_ => {}
559559
}
560560
}
561561
562562
buf.write_i8(tag);
563563
564-
match *self.lower() {
565-
Some(ref bound) => {
564+
match self.lower() {
565+
Some(bound) => {
566566
let mut inner_buf = MemWriter::new();
567567
bound.value.raw_to_sql(&mut inner_buf);
568568
let inner_buf = inner_buf.unwrap();
@@ -571,8 +571,8 @@ macro_rules! to_range_impl(
571571
}
572572
None => {}
573573
}
574-
match *self.upper() {
575-
Some(ref bound) => {
574+
match self.upper() {
575+
Some(bound) => {
576576
let mut inner_buf = MemWriter::new();
577577
bound.value.raw_to_sql(&mut inner_buf);
578578
let inner_buf = inner_buf.unwrap();

types/range.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@ impl<S: BoundSided, T: Ord> RangeBound<S, T> {
207207
}
208208
}
209209

210-
struct OptBound<'a, S, T>(&'a Option<RangeBound<S, T>>);
210+
struct OptBound<'a, S, T>(Option<&'a RangeBound<S, T>>);
211211

212212
impl<'a, S: BoundSided, T: Ord> Ord for OptBound<'a, S, T> {
213213
fn lt(&self, other: &OptBound<'a, S, T>) -> bool {
214214
match (*self, *other) {
215-
(OptBound(&None), OptBound(&None)) => false,
216-
(OptBound(&None), _) => BoundSided::side(None::<S>) == Lower,
217-
(_, OptBound(&None)) => BoundSided::side(None::<S>) == Upper,
218-
(OptBound(&Some(ref a)), OptBound(&Some(ref b))) => a < b
215+
(OptBound(None), OptBound(None)) => false,
216+
(OptBound(None), _) => BoundSided::side(None::<S>) == Lower,
217+
(_, OptBound(None)) => BoundSided::side(None::<S>) == Upper,
218+
(OptBound(Some(a)), OptBound(Some(b))) => a < b
219219
}
220220
}
221221
}
@@ -267,18 +267,18 @@ impl<T: Ord+Normalizable> Range<T> {
267267
}
268268

269269
/// Returns the lower bound if it exists.
270-
pub fn lower<'a>(&'a self) -> &'a Option<RangeBound<LowerBound, T>> {
270+
pub fn lower<'a>(&'a self) -> Option<&'a RangeBound<LowerBound, T>> {
271271
match *self {
272-
Empty => &None,
273-
Normal(ref lower, _) => lower
272+
Normal(Some(ref lower), _) => Some(lower),
273+
_ => None
274274
}
275275
}
276276

277277
/// Returns the upper bound if it exists.
278-
pub fn upper<'a>(&'a self) -> &'a Option<RangeBound<UpperBound, T>> {
278+
pub fn upper<'a>(&'a self) -> Option<&'a RangeBound<UpperBound, T>> {
279279
match *self {
280-
Empty => &None,
281-
Normal(_, ref upper) => upper
280+
Normal(_, Some(ref upper)) => Some(upper),
281+
_ => None
282282
}
283283
}
284284

@@ -320,7 +320,7 @@ impl<T: Ord+Normalizable+Clone> Range<T> {
320320
let OptBound(upper) = cmp::min(OptBound(self.upper()),
321321
OptBound(other.upper()));
322322

323-
Range::new(lower.clone(), upper.clone())
323+
Range::new(lower.map(|v| v.clone()), upper.map(|v| v.clone()))
324324
}
325325
}
326326

@@ -467,7 +467,8 @@ mod test {
467467
assert_eq!(r1, (range!('(', ')')).intersect(&r1));
468468

469469
let r2 = range!('(' 10i32, ')');
470-
let exp = Range::new(r2.lower().clone(), r1.upper().clone());
470+
let exp = Range::new(r2.lower().map(|v| v.clone()),
471+
r1.upper().map(|v| v.clone()));
471472
assert_eq!(exp, r1.intersect(&r2));
472473
assert_eq!(exp, r2.intersect(&r1));
473474

0 commit comments

Comments
 (0)