diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-04-01 11:28:34 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-04-01 13:29:42 -0700 |
| commit | e98dce3e00a7b6bfd264418ef993bbf9cdb1f0b6 (patch) | |
| tree | 1569b4aa8d412df9c49904b8bddeb44d8d4ecef2 /src/libstd | |
| parent | d528aa9960cb9b937d8ef6c09905a6a8076d5f3a (diff) | |
| download | rust-e98dce3e00a7b6bfd264418ef993bbf9cdb1f0b6.tar.gz rust-e98dce3e00a7b6bfd264418ef993bbf9cdb1f0b6.zip | |
std: Changing the meaning of the count to splitn
This commit is an implementation of [RFC 979][rfc] which changes the meaning of the count parameter to the `splitn` function on strings and slices. The parameter now means the number of items that are returned from the iterator, not the number of splits that are made. [rfc]: https://github.com/rust-lang/rfcs/pull/979 Closes #23911 [breaking-change]
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/net/addr.rs | 2 | ||||
| -rw-r--r-- | src/libstd/path.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/os.rs | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index c45230e91ba..886f252fb19 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -441,7 +441,7 @@ impl ToSocketAddrs for str { } // split the string by ':' and convert the second part to u16 - let mut parts_iter = self.rsplitn(1, ':'); + let mut parts_iter = self.rsplitn(2, ':'); let port_str = try_opt!(parts_iter.next(), "invalid socket address"); let host = try_opt!(parts_iter.next(), "invalid socket address"); let port: u16 = try_opt!(port_str.parse().ok(), "invalid port value"); diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 9006ed33654..ee4b572335b 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -406,7 +406,7 @@ fn split_file_at_dot(file: &OsStr) -> (Option<&OsStr>, Option<&OsStr>) { // contents of the encoding and (2) new &OsStr values are produced // only from ASCII-bounded slices of existing &OsStr values. - let mut iter = os_str_as_u8_slice(file).rsplitn(1, |b| *b == b'.'); + let mut iter = os_str_as_u8_slice(file).rsplitn(2, |b| *b == b'.'); let after = iter.next(); let before = iter.next(); if before == Some(b"") { diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 7b13e951b9b..d2220bdec32 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -409,7 +409,7 @@ pub fn env() -> Env { }; fn parse(input: &[u8]) -> (OsString, OsString) { - let mut it = input.splitn(1, |b| *b == b'='); + let mut it = input.splitn(2, |b| *b == b'='); let key = it.next().unwrap().to_vec(); let default: &[u8] = &[]; let val = it.next().unwrap_or(default).to_vec(); |
