Stop using deriving for types with phantom params

This commit is contained in:
Steven Fackler 2014-03-08 21:41:31 -08:00
parent 2064ba86ad
commit a8cf28d428

View File

@ -1,8 +1,6 @@
//! Types dealing with ranges of values
#[macro_escape];
extern crate extra;
use std::cmp;
use std::fmt;
use std::i32;
@ -141,11 +139,9 @@ trait BoundSided {
}
/// A tag type representing an upper bound
#[deriving(Eq,Clone)]
pub enum UpperBound {}
/// A tag type representing a lower bound
#[deriving(Eq,Clone)]
pub enum LowerBound {}
impl BoundSided for UpperBound {
@ -172,7 +168,6 @@ pub enum BoundType {
/// Represents a one-sided bound.
///
/// The side is determined by the `S` phantom parameter.
#[deriving(Clone)]
pub struct RangeBound<S, T> {
/// The value of the bound
value: T,
@ -180,6 +175,15 @@ pub struct RangeBound<S, T> {
type_: BoundType
}
impl<S: BoundSided, T: Clone> Clone for RangeBound<S, T> {
fn clone(&self) -> RangeBound<S, T> {
RangeBound {
value: self.value.clone(),
type_: self.type_.clone(),
}
}
}
impl<S: BoundSided, T: fmt::Show> fmt::Show for RangeBound<S, T> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let chars = match self.type_ {