Skip to content

Commit 8d29e87

Browse files
committed
core::str::from_cstr uses from_cstr_len
1 parent e5cc919 commit 8d29e87

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/libcore/str.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,14 @@ Function: from_cstr
195195
Create a Rust string from a null-terminated C string
196196
*/
197197
unsafe fn from_cstr(cstr: sbuf) -> str {
198-
let res = [];
199198
let start = cstr;
200199
let curr = start;
201200
let i = 0u;
202201
while *curr != 0u8 {
203-
vec::push(res, *curr);
204202
i += 1u;
205203
curr = ptr::offset(start, i);
206204
}
207-
ret from_bytes(res);
205+
ret from_cstr_len(cstr, i);
208206
}
209207

210208
/*

0 commit comments

Comments
 (0)