diff options
Diffstat (limited to 'src/libstd/path')
| -rw-r--r-- | src/libstd/path/posix.rs | 4 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 88907951673..0808b2a4f42 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -390,6 +390,7 @@ impl Path { let v = if self.repr[0] == SEP_BYTE { self.repr[1..] } else { self.repr.as_slice() }; + let is_sep_byte: fn(&u8) -> bool = is_sep_byte; // coerce to fn ptr let mut ret = v.split(is_sep_byte); if v.is_empty() { // consume the empty "" component @@ -401,7 +402,8 @@ impl Path { /// Returns an iterator that yields each component of the path as Option<&str>. /// See components() for details. pub fn str_components<'a>(&'a self) -> StrComponents<'a> { - self.components().map(str::from_utf8) + let from_utf8: fn(&[u8]) -> Option<&str> = str::from_utf8; // coerce to fn ptr + self.components().map(from_utf8) } } diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 9e4a66e0e5e..4b8fb7fad6a 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -655,7 +655,8 @@ impl Path { None if repr.as_bytes()[0] == SEP_BYTE => repr.slice_from(1), None => repr }; - let ret = s.split_terminator(SEP).map(Some); + let some: fn(&'a str) -> Option<&'a str> = Some; // coerce to fn ptr + let ret = s.split_terminator(SEP).map(some); ret } @@ -666,6 +667,7 @@ impl Path { #![inline] x.unwrap().as_bytes() } + let convert: for<'b> fn(Option<&'b str>) -> &'b [u8] = convert; // coerce to fn ptr self.str_components().map(convert) } |
