Skip to content

Commit a6dd7dc

Browse files
committed
auto merge of #5971 : pcwalton/rust/is-absolute, r=pcwalton
r? @jdm last commit
2 parents 8205f73 + 2c5afa4 commit a6dd7dc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/libcore/path.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ pub trait GenericPath {
6767
fn is_restricted(&self) -> bool;
6868

6969
fn normalize(&self) -> Self;
70+
71+
fn is_absolute(&self) -> bool;
7072
}
7173

7274
#[cfg(windows)]
@@ -379,10 +381,11 @@ impl ToStr for PosixPath {
379381
// FIXME (#3227): when default methods in traits are working, de-duplicate
380382
// PosixPath and WindowsPath, most of their methods are common.
381383
impl GenericPath for PosixPath {
382-
383384
fn from_str(s: &str) -> PosixPath {
384385
let mut components = ~[];
385-
for str::each_split_nonempty(s, |c| c == '/') |s| { components.push(s.to_owned()) }
386+
for str::each_split_nonempty(s, |c| c == '/') |s| {
387+
components.push(s.to_owned())
388+
}
386389
let is_absolute = (s.len() != 0 && s[0] == '/' as u8);
387390
return PosixPath { is_absolute: is_absolute,
388391
components: components }
@@ -540,6 +543,10 @@ impl GenericPath for PosixPath {
540543
// ..self
541544
}
542545
}
546+
547+
fn is_absolute(&self) -> bool {
548+
self.is_absolute
549+
}
543550
}
544551

545552

@@ -563,7 +570,6 @@ impl ToStr for WindowsPath {
563570

564571

565572
impl GenericPath for WindowsPath {
566-
567573
fn from_str(s: &str) -> WindowsPath {
568574
let host;
569575
let device;
@@ -809,6 +815,10 @@ impl GenericPath for WindowsPath {
809815
components: normalize(self.components)
810816
}
811817
}
818+
819+
fn is_absolute(&self) -> bool {
820+
self.is_absolute
821+
}
812822
}
813823

814824

0 commit comments

Comments
 (0)