Update for cmp changes
This commit is contained in:
parent
e6b45ed291
commit
2a0f92a411
@ -13,7 +13,7 @@ use types::PostgresType;
|
||||
macro_rules! make_errors(
|
||||
($($code:expr => $error:ident),+) => (
|
||||
/// SQLSTATE error codes
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, TotalEq, Clone)]
|
||||
#[allow(missing_doc)]
|
||||
pub enum PostgresSqlState {
|
||||
$($error,)+
|
||||
|
@ -1240,7 +1240,7 @@ impl<'conn> PostgresStatement<'conn> {
|
||||
}
|
||||
|
||||
/// Information about a column of the result of a query.
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq, TotalEq)]
|
||||
pub struct ResultDescription {
|
||||
/// The name of the column
|
||||
pub name: String,
|
||||
|
@ -421,7 +421,7 @@ fn test_execute_counts() {
|
||||
assert_eq!(3, or_fail!(conn.execute("SELECT * FROM foo", [])));
|
||||
}
|
||||
|
||||
fn test_type<T: Eq+FromSql+ToSql, S: Str>(sql_type: &str, checks: &[(T, S)]) {
|
||||
fn test_type<T: PartialEq+FromSql+ToSql, S: Str>(sql_type: &str, checks: &[(T, S)]) {
|
||||
let conn = or_fail!(PostgresConnection::connect("postgres://postgres@localhost", &NoSsl));
|
||||
for &(ref val, ref repr) in checks.iter() {
|
||||
let stmt = or_fail!(conn.prepare(format!("SELECT {:s}::{}", *repr, sql_type).as_slice()));
|
||||
|
@ -4,7 +4,7 @@ use std::mem;
|
||||
use std::slice;
|
||||
|
||||
/// Information about a dimension of an array
|
||||
#[deriving(Eq, Clone, Show)]
|
||||
#[deriving(PartialEq, TotalEq, Clone, Show)]
|
||||
pub struct DimensionInfo {
|
||||
/// The size of the dimension
|
||||
pub len: uint,
|
||||
@ -70,7 +70,7 @@ trait InternalMutableArray<T>: MutableArray<T> {
|
||||
}
|
||||
|
||||
/// A multi-dimensional array
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, TotalEq, Clone)]
|
||||
pub struct ArrayBase<T> {
|
||||
info: Vec<DimensionInfo>,
|
||||
data: Vec<T>,
|
||||
|
@ -77,7 +77,7 @@ static RANGE_EMPTY: i8 = 0b0000_0001;
|
||||
macro_rules! make_postgres_type(
|
||||
($(#[$doc:meta] $oid:ident => $variant:ident $(member $member:ident)*),+) => (
|
||||
/// A Postgres type
|
||||
#[deriving(Eq, Clone, Show)]
|
||||
#[deriving(PartialEq, TotalEq, Clone, Show)]
|
||||
pub enum PostgresType {
|
||||
$(
|
||||
#[$doc]
|
||||
|
@ -125,7 +125,7 @@ impl Normalizable for Timespec {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq, TotalEq)]
|
||||
enum BoundSide {
|
||||
Upper,
|
||||
Lower
|
||||
@ -156,7 +156,7 @@ impl BoundSided for LowerBound {
|
||||
}
|
||||
|
||||
/// The type of a range bound
|
||||
#[deriving(Eq,Clone)]
|
||||
#[deriving(PartialEq, TotalEq, Clone)]
|
||||
pub enum BoundType {
|
||||
/// The bound includes its value
|
||||
Inclusive,
|
||||
@ -201,13 +201,15 @@ impl<S: BoundSided, T: fmt::Show> fmt::Show for RangeBound<S, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BoundSided, T: Eq> Eq for RangeBound<S, T> {
|
||||
impl<S: BoundSided, T: PartialEq> PartialEq for RangeBound<S, T> {
|
||||
fn eq(&self, other: &RangeBound<S, T>) -> bool {
|
||||
self.value == other.value && self.type_ == other.type_
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BoundSided, T: Ord> Ord for RangeBound<S, T> {
|
||||
impl<S: BoundSided, T: TotalEq> TotalEq for RangeBound<S, T> {}
|
||||
|
||||
impl<S: BoundSided, T: PartialOrd> PartialOrd for RangeBound<S, T> {
|
||||
fn lt(&self, other: &RangeBound<S, T>) -> bool {
|
||||
match (BoundSided::side(None::<S>), self.type_, other.type_) {
|
||||
(Upper, Exclusive, Inclusive)
|
||||
@ -217,7 +219,18 @@ impl<S: BoundSided, T: Ord> Ord for RangeBound<S, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BoundSided, T: Ord> RangeBound<S, T> {
|
||||
impl<S: BoundSided, T: TotalOrd> TotalOrd for RangeBound<S, T> {
|
||||
fn cmp(&self, other: &RangeBound<S, T>) -> Ordering {
|
||||
match (BoundSided::side(None::<S>), self.type_, other.type_,
|
||||
self.value.cmp(&other.value)) {
|
||||
(Upper, Exclusive, Inclusive, Equal) => Less,
|
||||
(Lower, Inclusive, Exclusive, Equal) => Greater,
|
||||
(_, _, _, ord) => ord,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BoundSided, T: PartialOrd> RangeBound<S, T> {
|
||||
/// Constructs a new range bound
|
||||
pub fn new(value: T, type_: BoundType) -> RangeBound<S, T> {
|
||||
RangeBound { value: value, type_: type_ }
|
||||
@ -236,14 +249,16 @@ impl<S: BoundSided, T: Ord> RangeBound<S, T> {
|
||||
|
||||
struct OptBound<'a, S, T>(Option<&'a RangeBound<S, T>>);
|
||||
|
||||
impl<'a, S: BoundSided, T: Eq> Eq for OptBound<'a, S, T> {
|
||||
impl<'a, S: BoundSided, T: PartialEq> PartialEq for OptBound<'a, S, T> {
|
||||
fn eq(&self, &OptBound(ref other): &OptBound<'a, S, T>) -> bool {
|
||||
let &OptBound(ref self_) = self;
|
||||
self_ == other
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, S: BoundSided, T: Ord> Ord for OptBound<'a, S, T> {
|
||||
impl<'a, S: BoundSided, T: TotalEq> TotalEq for OptBound<'a, S, T> {}
|
||||
|
||||
impl<'a, S: BoundSided, T: PartialOrd> PartialOrd for OptBound<'a, S, T> {
|
||||
fn lt(&self, other: &OptBound<'a, S, T>) -> bool {
|
||||
match (*self, *other) {
|
||||
(OptBound(None), OptBound(None)) => false,
|
||||
@ -255,12 +270,12 @@ impl<'a, S: BoundSided, T: Ord> Ord for OptBound<'a, S, T> {
|
||||
}
|
||||
|
||||
/// Represents a range of values.
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, TotalEq, Clone)]
|
||||
pub struct Range<T> {
|
||||
inner: InnerRange<T>,
|
||||
}
|
||||
|
||||
#[deriving(Eq,Clone)]
|
||||
#[deriving(PartialEq, TotalEq, Clone)]
|
||||
enum InnerRange<T> {
|
||||
Empty,
|
||||
Normal(Option<RangeBound<LowerBound, T>>,
|
||||
@ -286,7 +301,7 @@ impl<T: fmt::Show> fmt::Show for Range<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Ord+Normalizable> Range<T> {
|
||||
impl<T: PartialOrd+Normalizable> Range<T> {
|
||||
/// Creates a new range.
|
||||
///
|
||||
/// If a bound is `None`, the range is unbounded in that direction.
|
||||
@ -366,7 +381,7 @@ impl<T: Ord+Normalizable> Range<T> {
|
||||
}
|
||||
}
|
||||
|
||||
fn order<T:Ord>(a: T, b: T) -> (T, T) {
|
||||
fn order<T:PartialOrd>(a: T, b: T) -> (T, T) {
|
||||
if a < b {
|
||||
(a, b)
|
||||
} else {
|
||||
@ -374,7 +389,7 @@ fn order<T:Ord>(a: T, b: T) -> (T, T) {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Ord+Normalizable+Clone> Range<T> {
|
||||
impl<T: PartialOrd+Normalizable+Clone> Range<T> {
|
||||
/// Returns the intersection of this range with another
|
||||
pub fn intersect(&self, other: &Range<T>) -> Range<T> {
|
||||
if self.is_empty() || other.is_empty() {
|
||||
|
Loading…
Reference in New Issue
Block a user