Skip to content

Commit e30c999

Browse files
committed
---
yaml --- r: 23995 b: refs/heads/master c: e3f5403 h: refs/heads/master i: 23993: 0e09686 23991: 5caed02 v: v3
1 parent 7c2af67 commit e30c999

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d0d68c6036275c0a190ad100d6eb36a537b76d80
2+
refs/heads/master: e3f5403052e53b557998315fae780b5431a8ce0b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/str.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,10 +1967,10 @@ mod raw {
19671967
export
19681968
from_buf,
19691969
from_buf_len,
1970-
from_buf_len_nocopy,
19711970
from_c_str,
19721971
from_c_str_len,
19731972
from_bytes,
1973+
form_slice,
19741974
slice_bytes,
19751975
view_bytes,
19761976
push_byte,
@@ -2003,14 +2003,6 @@ mod raw {
20032003
return ::unsafe::transmute(move v);
20042004
}
20052005

2006-
/// Create a Rust string from a *u8 buffer of the given length
2007-
/// without copying
2008-
unsafe fn from_buf_len_nocopy(buf: &a / *u8, len: uint) -> &a / str {
2009-
let v = (*buf, len + 1);
2010-
assert is_utf8(::unsafe::reinterpret_cast(&v));
2011-
return ::unsafe::transmute(move v);
2012-
}
2013-
20142006
/// Create a Rust string from a null-terminated C string
20152007
unsafe fn from_c_str(c_str: *libc::c_char) -> ~str {
20162008
from_buf(::unsafe::reinterpret_cast(&c_str))
@@ -2031,6 +2023,13 @@ mod raw {
20312023
/// Converts a byte to a string.
20322024
unsafe fn from_byte(u: u8) -> ~str { raw::from_bytes([u]) }
20332025

2026+
/// Form a slice from a *u8 buffer of the given length without copying.
2027+
unsafe fn buf_as_slice<T>(buf: *u8, len: uint, f: fn(&& &str) -> T) -> T {
2028+
let v = (*buf, len + 1);
2029+
assert is_utf8(::unsafe::reinterpret_cast(&v));
2030+
f(::unsafe::transmute(move v))
2031+
}
2032+
20342033
/**
20352034
* Takes a bytewise (not UTF-8) slice from a string.
20362035
*

0 commit comments

Comments
 (0)