Skip to content

Commit 5bfd020

Browse files
committed
Update for upstream changes
1 parent 42c6255 commit 5bfd020

3 files changed

Lines changed: 49 additions & 9 deletions

File tree

src/test.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,16 +314,16 @@ fn test_lazy_query() {
314314
fn test_param_types() {
315315
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
316316
let stmt = conn.prepare("SELECT $1::INT, $2::VARCHAR");
317-
assert_eq!(stmt.param_types(), [PgInt4, PgVarchar]);
317+
assert_eq!(stmt.param_types(), &[PgInt4, PgVarchar]);
318318
}
319319

320320
#[test]
321321
fn test_result_descriptions() {
322322
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
323323
let stmt = conn.prepare("SELECT 1::INT as a, 'hi'::VARCHAR as b");
324-
assert_eq!(stmt.result_descriptions(),
325-
[ResultDescription { name: ~"a", ty: PgInt4},
326-
ResultDescription { name: ~"b", ty: PgVarchar}]);
324+
assert!(stmt.result_descriptions() ==
325+
[ResultDescription { name: ~"a", ty: PgInt4},
326+
ResultDescription { name: ~"b", ty: PgVarchar}]);
327327
}
328328
329329
#[test]
@@ -344,11 +344,11 @@ fn test_type<T: Eq+FromSql+ToSql, S: Str>(sql_type: &str, checks: &[(T, S)]) {
344344
for &(ref val, ref repr) in checks.iter() {
345345
let stmt = conn.prepare(format!("SELECT {:s}::{}", *repr, sql_type));
346346
let result = stmt.query([]).next().unwrap()[1];
347-
assert_eq!(val, &result);
347+
assert!(val == &result);
348348

349349
let stmt = conn.prepare("SELECT $1::" + sql_type);
350350
let result = stmt.query([val as &ToSql]).next().unwrap()[1];
351-
assert_eq!(val, &result);
351+
assert!(val == &result);
352352
}
353353
}
354354

src/types/array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::cast;
44
use std::vec;
55

66
/// Information about a dimension of an array
7-
#[deriving(Eq, Clone)]
7+
#[deriving(Eq, Clone, Show)]
88
pub struct DimensionInfo {
99
/// The size of the dimension
1010
len: uint,
@@ -253,8 +253,8 @@ mod tests {
253253
#[test]
254254
fn test_from_vec() {
255255
let a = ArrayBase::from_vec(~[0, 1, 2], -1);
256-
assert_eq!([DimensionInfo { len: 3, lower_bound: -1 }],
257-
a.dimension_info());
256+
assert!([DimensionInfo { len: 3, lower_bound: -1 }] ==
257+
a.dimension_info());
258258
assert_eq!(&0, a.get(-1));
259259
assert_eq!(&1, a.get(0));
260260
assert_eq!(&2, a.get(1));

src/types/range.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
extern crate extra;
55

66
use std::cmp;
7+
use std::fmt;
78
use std::i32;
89
use std::i64;
910
use time::Timespec;
@@ -179,6 +180,26 @@ pub struct RangeBound<S, T> {
179180
type_: BoundType
180181
}
181182

183+
impl<S: BoundSided, T: fmt::Show> fmt::Show for RangeBound<S, T> {
184+
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
185+
let chars = match self.type_ {
186+
Inclusive => ['[', ']'],
187+
Exclusive => ['(', ')'],
188+
};
189+
190+
match BoundSided::side(None::<S>) {
191+
Lower => {
192+
try!(formatter.buf.write_char(chars[0]));
193+
self.value.fmt(formatter)
194+
}
195+
Upper => {
196+
try!(self.value.fmt(formatter));
197+
formatter.buf.write_char(chars[1])
198+
}
199+
}
200+
}
201+
}
202+
182203
impl<S: BoundSided, T: Ord> Ord for RangeBound<S, T> {
183204
fn lt(&self, other: &RangeBound<S, T>) -> bool {
184205
match (BoundSided::side(None::<S>), self.type_, other.type_) {
@@ -227,6 +248,25 @@ pub enum Range<T> {
227248
Option<RangeBound<UpperBound, T>>)
228249
}
229250

251+
impl<T: fmt::Show> fmt::Show for Range<T> {
252+
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
253+
match *self {
254+
Empty => formatter.buf.write_str("empty"),
255+
Normal(ref lower, ref upper) => {
256+
match *lower {
257+
Some(ref bound) => try!(bound.fmt(formatter)),
258+
None => try!(formatter.buf.write_char('(')),
259+
}
260+
try!(formatter.buf.write_char(','));
261+
match *upper {
262+
Some(ref bound) => bound.fmt(formatter),
263+
None => formatter.buf.write_char(')'),
264+
}
265+
}
266+
}
267+
}
268+
}
269+
230270
impl<T: Ord+Normalizable> Range<T> {
231271
/// Creates a new range.
232272
///

0 commit comments

Comments
 (0)