We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e5cc919 commit 8d29e87Copy full SHA for 8d29e87
src/libcore/str.rs
@@ -195,16 +195,14 @@ Function: from_cstr
195
Create a Rust string from a null-terminated C string
196
*/
197
unsafe fn from_cstr(cstr: sbuf) -> str {
198
- let res = [];
199
let start = cstr;
200
let curr = start;
201
let i = 0u;
202
while *curr != 0u8 {
203
- vec::push(res, *curr);
204
i += 1u;
205
curr = ptr::offset(start, i);
206
}
207
- ret from_bytes(res);
+ ret from_cstr_len(cstr, i);
208
209
210
/*
0 commit comments