diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-22 12:51:23 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-22 12:51:23 -0800 |
| commit | de11710d807bed5c0a29cc0413d404552a42c89d (patch) | |
| tree | a352475a1db5cdc5a19f557ba66a375766cda87c /src/libstd/path | |
| parent | 459f3b2cfa0e618d6e28ce564a363a9477567f71 (diff) | |
| parent | 763152b995bb506ac88c852a030c84a012bcf983 (diff) | |
| download | rust-de11710d807bed5c0a29cc0413d404552a42c89d.tar.gz rust-de11710d807bed5c0a29cc0413d404552a42c89d.zip | |
rollup merge of #19891: nikomatsakis/unique-fn-types-3
Conflicts: src/libcore/str.rs src/librustc_trans/trans/closure.rs src/librustc_typeck/collect.rs src/libstd/path/posix.rs src/libstd/path/windows.rs
Diffstat (limited to 'src/libstd/path')
| -rw-r--r-- | src/libstd/path/posix.rs | 4 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index a514837492a..f0a00b421c3 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 @@ -404,7 +405,8 @@ impl Path { fn from_utf8(s: &[u8]) -> Option<&str> { str::from_utf8(s).ok() } - self.components().map(from_utf8) + let f: fn(&[u8]) -> Option<&str> = from_utf8; // coerce to fn ptr + self.components().map(f) } } diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 277c675c22d..b24966241ff 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -651,7 +651,8 @@ impl Path { None if repr.as_bytes()[0] == SEP_BYTE => repr[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 } @@ -662,6 +663,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) } @@ -1044,7 +1046,11 @@ fn parse_prefix<'a>(mut path: &'a str) -> Option<PathPrefix> { // None result means the string didn't need normalizing fn normalize_helper<'a>(s: &'a str, prefix: Option<PathPrefix>) -> (bool, Option<Vec<&'a str>>) { - let f = if !prefix_is_verbatim(prefix) { is_sep } else { is_sep_verbatim }; + let f: fn(char) -> bool = if !prefix_is_verbatim(prefix) { + is_sep + } else { + is_sep_verbatim + }; let is_abs = s.len() > prefix_len(prefix) && f(s.char_at(prefix_len(prefix))); let s_ = s[prefix_len(prefix)..]; let s_ = if is_abs { s_[1..] } else { s_ }; |
