Replace some Eq impls with deriving_eq
This commit is contained in:
parent
742f354ffb
commit
d809e89c26
13 changed files with 24 additions and 263 deletions
|
@ -20,6 +20,7 @@ Cross-platform file path handling
|
|||
|
||||
use cmp::Eq;
|
||||
|
||||
#[deriving_eq]
|
||||
pub struct WindowsPath {
|
||||
host: Option<~str>,
|
||||
device: Option<~str>,
|
||||
|
@ -31,6 +32,7 @@ pub pure fn WindowsPath(s: &str) -> WindowsPath {
|
|||
from_str(s)
|
||||
}
|
||||
|
||||
#[deriving_eq]
|
||||
pub struct PosixPath {
|
||||
is_absolute: bool,
|
||||
components: ~[~str],
|
||||
|
@ -356,24 +358,6 @@ impl PosixPath : ToStr {
|
|||
}
|
||||
}
|
||||
|
||||
impl PosixPath : Eq {
|
||||
pure fn eq(&self, other: &PosixPath) -> bool {
|
||||
return (*self).is_absolute == (*other).is_absolute &&
|
||||
(*self).components == (*other).components;
|
||||
}
|
||||
pure fn ne(&self, other: &PosixPath) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
impl WindowsPath : Eq {
|
||||
pure fn eq(&self, other: &WindowsPath) -> bool {
|
||||
return (*self).host == (*other).host &&
|
||||
(*self).device == (*other).device &&
|
||||
(*self).is_absolute == (*other).is_absolute &&
|
||||
(*self).components == (*other).components;
|
||||
}
|
||||
pure fn ne(&self, other: &WindowsPath) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
// FIXME (#3227): when default methods in traits are working, de-duplicate
|
||||
// PosixPath and WindowsPath, most of their methods are common.
|
||||
impl PosixPath : GenericPath {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue