From 708b5d986e37eeb61a98b2a7f29ba02f517e7d39 Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Sun, 10 Jun 2012 08:30:43 -0700 Subject: [PATCH] core: str::as_slice is unneeded, yay! fixes std::net::tcp socket_buf test i mistook an "unconstrained type" error, due to type-inference messup because i didnt have return vals in some closure wired-up right, for being due to not having a str as a str/& (a str will actually auto-coerce to a str/&, so str::as_slice was erroneously added. my bad). --- src/libcore/str.rs | 11 ----------- src/libstd/net_tcp.rs | 12 +++++------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 2c0f4b4a96b..35d2edd608a 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -23,7 +23,6 @@ export as_buf, as_c_str, unpack_slice, - as_slice, // Adding things to and removing things from a string push_char, @@ -1621,16 +1620,6 @@ pure fn unpack_slice(s: str/&, f: fn(*u8, uint) -> T) -> T { } } -pure fn as_slice(s: str, - start: uint, end: uint, - f: fn(str/&) -> T) -> T unsafe { - assert (start <= end); - assert (end <= len(s)); - let p = ptr::addr_of(s); - f(::unsafe::reinterpret_cast( - (ptr::offset(p, start), (end - start) * sys::size_of::()))) -} - #[doc = " Reserves capacity for exactly `n` bytes in the given string, not including the null terminator. diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 06829312849..6718e3729f7 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -1456,7 +1456,7 @@ mod test { buf_read(sock_buf as io::reader, vec::len(resp_buf)) }; - + let actual_req = comm::recv(server_result_po); log(debug, #fmt("REQ: expected: '%s' actual: '%s'", expected_req, actual_req)); @@ -1468,12 +1468,10 @@ mod test { fn buf_write(+w: io::writer, val: str) { log(debug, #fmt("BUF_WRITE: val len %?", str::len(val))); - str::as_slice(val, 0u, str::len(val) -1u) {|val_slice| - str::byte_slice(val_slice) {|b_slice| - log(debug, #fmt("BUF_WRITE: b_slice len %?", - vec::len(b_slice))); - w.write(b_slice) - } + str::byte_slice(val) {|b_slice| + log(debug, #fmt("BUF_WRITE: b_slice len %?", + vec::len(b_slice))); + w.write(b_slice) } }