Skip to content

Commit 64de6d6

Browse files
committed
core: Fix mode warnings in str
1 parent 996ec62 commit 64de6d6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/libcore/str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,10 +1827,10 @@ const tag_six_b: uint = 252u;
18271827
* let i = str::as_bytes("Hello World") { |bytes| vec::len(bytes) };
18281828
* ~~~
18291829
*/
1830-
pure fn as_bytes<T>(s: &const ~str, f: fn(~[u8]) -> T) -> T {
1830+
pure fn as_bytes<T>(s: &const ~str, f: fn((&~[u8])) -> T) -> T {
18311831
unsafe {
18321832
let v: *~[u8] = cast::transmute(copy s);
1833-
f(*v)
1833+
f(&*v)
18341834
}
18351835
}
18361836

@@ -1945,7 +1945,7 @@ fn reserve_at_least(s: &const ~str, n: uint) {
19451945
*/
19461946
pure fn capacity(s: &const ~str) -> uint {
19471947
do as_bytes(s) |buf| {
1948-
let vcap = vec::capacity(buf);
1948+
let vcap = vec::capacity(*buf);
19491949
assert vcap > 0u;
19501950
vcap - 1u
19511951
}
@@ -2037,7 +2037,7 @@ mod raw {
20372037

20382038
/// Form a slice from a *u8 buffer of the given length without copying.
20392039
unsafe fn buf_as_slice<T>(buf: *u8, len: uint,
2040-
f: fn(&&v: &str) -> T) -> T {
2040+
f: fn(v: &str) -> T) -> T {
20412041
let v = (buf, len + 1);
20422042
assert is_utf8(::cast::reinterpret_cast(&v));
20432043
f(::cast::transmute(move v))

src/rustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] {
11751175
// vec::from_slice(metadata_encoding_version) +
11761176

11771177
(do str::as_bytes(&~"rust\x00\x00\x00\x01") |bytes| {
1178-
vec::slice(bytes, 0, 8)
1178+
vec::slice(*bytes, 0, 8)
11791179
}) + flate::deflate_bytes(wr.buf.check_out(|buf| buf))
11801180
}
11811181

0 commit comments

Comments
 (0)