Skip to content

Commit 9ad815e

Browse files
committed
std: rename str.as_bytes_with_null_consume to str.to_bytes_with_null
1 parent 7434080 commit 9ad815e

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/libextra/terminfo/parm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ priv fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
545545
String(s) => {
546546
match op {
547547
FormatString => {
548-
let mut s = s.as_bytes_with_null_consume();
548+
let mut s = s.to_bytes_with_null();
549549
s.pop(); // remove the null
550550
if flags.precision > 0 && flags.precision < s.len() {
551551
s.truncate(flags.precision);

src/libstd/str.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,8 +2073,7 @@ pub trait OwnedStr {
20732073
fn reserve(&mut self, n: uint);
20742074
fn reserve_at_least(&mut self, n: uint);
20752075
fn capacity(&self) -> uint;
2076-
2077-
fn as_bytes_with_null_consume(self) -> ~[u8];
2076+
fn to_bytes_with_null(self) -> ~[u8];
20782077
}
20792078
20802079
impl OwnedStr for ~str {
@@ -2263,7 +2262,7 @@ impl OwnedStr for ~str {
22632262
/// Convert to a vector of bytes. This does not allocate a new
22642263
/// string, and includes the null terminator.
22652264
#[inline]
2266-
fn as_bytes_with_null_consume(self) -> ~[u8] {
2265+
fn to_bytes_with_null(self) -> ~[u8] {
22672266
unsafe { ::cast::transmute(self) }
22682267
}
22692268
}
@@ -3065,17 +3064,17 @@ mod tests {
30653064
}
30663065
30673066
#[test]
3068-
fn test_as_bytes_with_null_consume() {
3067+
fn test_to_bytes_with_null() {
30693068
let s = ~"ศไทย中华Việt Nam";
30703069
let v = ~[
30713070
224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228,
30723071
184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97,
30733072
109, 0
30743073
];
3075-
assert_eq!((~"").as_bytes_with_null_consume(), ~[0]);
3076-
assert_eq!((~"abc").as_bytes_with_null_consume(),
3074+
assert_eq!((~"").to_bytes_with_null(), ~[0]);
3075+
assert_eq!((~"abc").to_bytes_with_null(),
30773076
~['a' as u8, 'b' as u8, 'c' as u8, 0]);
3078-
assert_eq!(s.as_bytes_with_null_consume(), v);
3077+
assert_eq!(s.to_bytes_with_null(), v);
30793078
}
30803079
30813080
#[test]

src/test/run-pass/foreign-fn-linkname.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod libc {
2626
fn strlen(str: ~str) -> uint {
2727
unsafe {
2828
// C string is terminated with a zero
29-
let bytes = str.as_bytes_with_null_consume();
29+
let bytes = str.to_bytes_with_null();
3030
return libc::my_strlen(vec::raw::to_ptr(bytes));
3131
}
3232
}

0 commit comments

Comments
 (0)