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 005a3ef commit 6408d54Copy full SHA for 6408d54
src/libcore/str.rs
@@ -17,6 +17,7 @@ export
17
from_char,
18
from_chars,
19
from_cstr,
20
+ from_cstr_len,
21
concat,
22
connect,
23
@@ -210,6 +211,24 @@ unsafe fn from_cstr(cstr: sbuf) -> str {
210
211
ret from_bytes(res);
212
}
213
214
+/*
215
+Function: from_cstr_len
216
+
217
+Create a Rust string from a C string of the given length
218
+*/
219
+unsafe fn from_cstr_len(cstr: sbuf, len: uint) -> str {
220
+ let res = [];
221
+ let start = cstr;
222
+ let curr = start;
223
+ let i = 0u;
224
+ while i < len {
225
+ vec::push(res, *curr);
226
+ i += 1u;
227
+ curr = ptr::offset(start, i);
228
+ }
229
+ ret from_bytes(res);
230
+}
231
232
/*
233
Function: concat
234
0 commit comments