1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
use std::cmp::min;
use std::cmp::{Ordering, PartialEq, PartialOrd};
use std::convert::From;
use std::ffi::CStr;
use std::slice;
hicc::cpp! {
#include <string>
}
hicc::import_class! {
#[cpp(class = "template<class CharT, class Traits, class Allocator> std::basic_string<CharT, Traits, Allocator>")]
pub class basic_string<CharT> {
pub const npos: usize = usize::MAX;
/// ```
/// use std::ffi::CStr;
/// use hicc_std::string;
/// let s = string::from(hicc::cstr!("abc"));
/// let cstr = unsafe { CStr::from_ptr(s.c_str()) };
/// assert_eq!(cstr, hicc::cstr!("abc"));
/// ```
#[cpp(method = "const CharT* c_str() const")]
pub fn c_str(&self) -> *const CharT;
/// ```
/// use hicc_std::string;
/// let s = string::new();
/// assert!(s.is_empty());
/// ```
#[cpp(method = "bool empty() const")]
pub fn is_empty(&self) -> bool;
/// ```
/// use hicc_std::string;
/// let s = string::new();
/// assert_eq!(s.size(), 0);
/// ```
#[cpp(method = "size_t size() const")]
pub fn size(&self) -> usize;
/// ```
/// use hicc_std::string;
/// let s = string::new();
/// println!("s.max_size = {}", s.max_size());
/// ```
#[cpp(method = "size_t max_size() const")]
pub fn max_size(&self) -> usize;
/// ```
/// use hicc_std::string;
/// let s = string::new();
/// println!("s.capacity = {}", s.capacity());
/// ```
#[cpp(method = "size_t capacity() const")]
pub fn capacity(&self) -> usize;
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("a"));
/// s.resize(3, b'c' as i8);
/// assert_eq!(s.as_cstr(), hicc::cstr!("acc"));
/// ```
#[cpp(method = "void resize(size_t, CharT) ")]
pub fn resize(&mut self, n: usize, c: CharT);
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// s.reserve(100);
/// println!("s.capacity = {}", s.capacity());
/// ```
#[cpp(method = "void reserve(size_t)")]
pub fn reserve(&mut self, n: usize);
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// s.clear();
/// assert!(s.is_empty());
/// ```
#[cpp(method = "void clear()")]
pub fn clear(&mut self);
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// s.reserve(100);
/// println!("before shrink_to_fit: capacity = {}", s.capacity());
/// s.assign(10, b'c' as i8);
/// s.shrink_to_fit();
/// println!("after shrink_to_fit: capacity = {}", s.capacity());
/// ```
#[cpp(method = "void shrink_to_fit()")]
pub fn shrink_to_fit(&mut self);
/// 如果pos超出范围,会返回空字符串.
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// let substr = s.substr(1, 2);
/// assert_eq!(substr.as_cstr(), hicc::cstr!("bc"));
/// ```
pub fn substr(&self, mut pos: usize, len: usize) -> Self {
if pos > self.size() {
pos = self.size();
}
self._substr(pos, len)
}
#[cpp(method = "Self substr(size_t, size_t) const")]
fn _substr(&self, pos: usize, len: usize) -> Self;
/// ```
/// use hicc_std::string;
/// let s1 = string::from(hicc::cstr!("abc"));
/// let s2 = string::from(hicc::cstr!("abd"));
/// assert!(s1 < s2);
/// assert!(s1 != s2);
/// ```
#[cpp(method = "int compare(const Self&) const")]
pub fn compare(&self, other: &Self) -> i32;
/// ```
/// use hicc_std::string;
/// let s1 = string::from(hicc::cstr!("abcdef"));
/// let s2 = string::from(hicc::cstr!("bcd"));
/// assert_eq!(s1.find_str(&s2, 0), 1);
/// ```
#[cpp(method = "size_t find(const Self&, size_t) const")]
pub fn find_str(&self, target: &Self, pos: usize) -> usize;
/// ```
/// use hicc_std::string;
/// let s = string::from(hicc::cstr!("abcdef"));
/// assert_eq!(s.find(b'c' as i8, 1), 2);
/// ```
#[cpp(method = "size_t find(CharT, size_t) const")]
pub fn find(&self, c: CharT, pos: usize) -> usize;
/// ```
/// use hicc_std::string;
/// let s1 = string::from(hicc::cstr!("abcdef"));
/// let s2 = string::from(hicc::cstr!("bcd"));
/// assert_eq!(s1.rfind_str(&s2, string::npos), 1);
/// ```
#[cpp(method = "size_t rfind(const Self&, size_t) const")]
pub fn rfind_str(&self, target: &Self, pos: usize) -> usize;
/// ```
/// use hicc_std::string;
/// let s = string::from(hicc::cstr!("abcdef"));
/// assert_eq!(s.rfind(b'c' as i8, string::npos), 2);
/// ```
#[cpp(method = "size_t rfind(CharT, size_t) const")]
pub fn rfind(&self, c: CharT, pos: usize) -> usize;
/// ```
/// use hicc_std::string;
/// let s1 = string::from(hicc::cstr!("abcdef"));
/// let s2 = string::from(hicc::cstr!("dfb"));
/// assert_eq!(s1.find_first_of(&s2, 0), 1);
/// ```
#[cpp(method = "size_t find_first_of(const Self&, size_t) const")]
pub fn find_first_of(&self, target: &Self, pos: usize) -> usize;
/// ```
/// use hicc_std::string;
/// let s = string::from(hicc::cstr!("abcabc"));
/// assert_eq!(s.find_first(b'c' as i8, 0), 2);
/// ```
#[cpp(method = "size_t find_first_of(CharT, size_t) const")]
pub fn find_first(&self, c: CharT, pos: usize) -> usize;
/// ```
/// use hicc_std::string;
/// let s1 = string::from(hicc::cstr!("abcdef"));
/// let s2 = string::from(hicc::cstr!("dfb"));
/// assert_eq!(s1.find_last_of(&s2, string::npos), 5);
/// ```
#[cpp(method = "size_t find_last_of(const Self&, size_t) const")]
pub fn find_last_of(&self, target: &Self, pos: usize) -> usize;
/// ```
/// use hicc_std::string;
/// let s = string::from(hicc::cstr!("abcabc"));
/// assert_eq!(s.find_last(b'c' as i8, string::npos), 5);
/// ```
#[cpp(method = "size_t find_last_of(CharT, size_t) const")]
pub fn find_last(&self, c: CharT, pos: usize) -> usize;
/// ```
/// use hicc_std::string;
/// let s1 = string::from(hicc::cstr!("abcdef"));
/// let s2 = string::from(hicc::cstr!("abc"));
/// assert_eq!(s1.find_first_not_of(&s2, 0), 3);
/// ```
#[cpp(method = "size_t find_first_not_of(const Self&, size_t) const")]
pub fn find_first_not_of(&self, target: &Self, pos: usize) -> usize;
/// ```
/// use hicc_std::string;
/// let s = string::from(hicc::cstr!("abcabc"));
/// assert_eq!(s.find_first_not(b'a' as i8, 0), 1);
/// ```
#[cpp(method = "size_t find_first_not_of(CharT, size_t) const")]
pub fn find_first_not(&self, c: CharT, pos: usize) -> usize;
/// ```
/// use hicc_std::string;
/// let s1 = string::from(hicc::cstr!("abcdef"));
/// let s2 = string::from(hicc::cstr!("def"));
/// assert_eq!(s1.find_last_not_of(&s2, string::npos), 2);
/// ```
#[cpp(method = "size_t find_last_not_of(const Self&, size_t) const")]
pub fn find_last_not_of(&self, target: &Self, pos: usize) -> usize;
/// ```
/// use hicc_std::string;
/// let s = string::from(hicc::cstr!("abcabc"));
/// assert_eq!(s.find_last_not(b'c' as i8, string::npos), 4);
/// ```
#[cpp(method = "size_t find_last_not_of(CharT, size_t) const")]
pub fn find_last_not(&self, c: CharT, pos: usize) -> usize;
/// 如果subpos超出范围则不做任何改变.
/// ```
/// use hicc_std::string;
/// let mut s1 = string::from(hicc::cstr!("abc"));
/// let s2 = string::from(hicc::cstr!("def"));
/// s1.append_str(&s2, 0, 2);
/// assert_eq!(s1.as_cstr(), hicc::cstr!("abcde"));
/// ```
pub fn append_str(&mut self, s: &Self, subpos: usize, sublen: usize) {
if subpos < s.size() {
self._append_str(s, subpos, sublen);
}
}
#[cpp(method = "Self& append(const Self&, size_t, size_t)")]
fn _append_str(&mut self, s: &Self, subpos: usize, sublen: usize);
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// s.append(1, b'd' as i8);
/// assert_eq!(s.as_cstr(), hicc::cstr!("abcd"));
/// ```
#[cpp(method = "Self& append(size_t, CharT)")]
pub fn append(&mut self, n: usize, c: CharT);
/// 如果subpos超出范围不做任何改变, 如果pos超出范围则追加到最后.
/// ```
/// use hicc_std::string;
/// let mut s1 = string::from(hicc::cstr!("abc"));
/// let mut s2 = string::from(hicc::cstr!("def"));
/// s1.insert_str(0, &s2, 0, string::npos);
/// assert_eq!(s1.as_cstr(), hicc::cstr!("defabc"));
/// s1.insert_str(100, &s2, 0, string::npos);
/// assert_eq!(s1.as_cstr(), hicc::cstr!("defabcdef"));
/// ```
pub fn insert_str(&mut self, pos: usize, s: &Self, subpos: usize, sublen: usize) {
if subpos < s.size() {
self._insert_str(min(pos, self.size()), s, subpos, sublen);
}
}
#[cpp(method = "Self& insert(size_t, const Self&, size_t, size_t)")]
fn _insert_str(&mut self, pos: usize, s: &Self, subpos: usize, sublen: usize);
/// 如果pos超出范围则追加到最后.
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// s.insert(0, 3, b'd' as i8);
/// assert_eq!(s.as_cstr(), hicc::cstr!("dddabc"));
/// s.insert(110, 3, b'd' as i8);
/// assert_eq!(s.as_cstr(), hicc::cstr!("dddabcddd"));
/// ```
pub fn insert(&mut self, pos: usize, n: usize, c: CharT::InputType) {
self._insert(min(pos, self.size()), n, c);
}
#[cpp(method = "Self& insert(size_t, size_t, CharT)")]
fn _insert(&mut self, pos: usize, n: usize, c: CharT);
/// 如果pos或者subpos超出范围则不做任何改变.
/// ```
/// use hicc_std::string;
/// let mut s1 = string::from(hicc::cstr!("abc"));
/// let mut s2 = string::from(hicc::cstr!("de"));
/// s1.replace_str(0, string::npos, &s2, 0, string::npos);
/// assert_eq!(s1.as_cstr(), hicc::cstr!("de"));
/// ```
pub fn replace_str(&mut self, pos: usize, len: usize, s: &Self, subpos: usize, sublen: usize) {
if pos < self.size() && subpos < s.size() {
self._replace_str(pos, len, s, subpos, sublen);
}
}
#[cpp(method = "Self& replace(size_t, size_t, const Self&, size_t, size_t)")]
fn _replace_str(&mut self, pos: usize, len: usize, s: &Self, subpos: usize, sublen: usize);
/// 如果pos超出范围则不做任何改变.
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// s.replace(0, string::npos, 1, b'd' as i8);
/// assert_eq!(s.as_cstr(), hicc::cstr!("d"));
/// ```
pub fn replace(&mut self, pos: usize, len: usize, n: usize, c: CharT::InputType) {
if pos < self.size() {
self._replace(pos, len, n, c);
}
}
#[cpp(method = "Self& replace(size_t, size_t, size_t, CharT)")]
fn _replace(&mut self, pos: usize, len: usize, n: usize, c: CharT);
/// 如果subpos超出范围则不做任何改变.
/// ```
/// use hicc_std::string;
/// let mut s1 = string::from(hicc::cstr!("abc"));
/// let mut s2 = string::from(hicc::cstr!("de"));
/// s1.assign_str(&s2, 0, string::npos);
/// assert_eq!(s1.as_cstr(), hicc::cstr!("de"));
/// ```
pub fn assign_str(&mut self, s: &Self, subpos: usize, sublen: usize) {
if subpos < s.size() {
self._assign_str(s, subpos, sublen);
}
}
#[cpp(method = "Self& assign(const Self&, size_t, size_t)")]
fn _assign_str(&mut self, s: &Self, subpos: usize, sublen: usize);
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// s.assign(1, b'd' as i8);
/// assert_eq!(s.as_cstr(), hicc::cstr!("d"));
/// ```
#[cpp(method = "Self& assign(size_t, CharT)")]
pub fn assign(&mut self, n: usize, c: CharT);
/// 如果pos超出范围则不做任何改变.
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// s.erase(1, 1);
/// assert_eq!(s.as_cstr(), hicc::cstr!("ac"));
/// ```
pub fn erase(&mut self, pos: usize, len: usize) {
if pos < self.size() {
self._erase(pos, len);
}
}
#[cpp(method = "Self& erase(size_t, size_t)")]
fn _erase(&mut self, pos: usize, len: usize);
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// s.push_back(b'd' as i8);
/// assert_eq!(s.as_cstr(), hicc::cstr!("abcd"));
/// ```
#[cpp(method = "void push_back(CharT)")]
pub fn push_back(&mut self, c: CharT);
/// 如果为空则不做任何改变.
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// s.pop_back();
/// assert_eq!(s.as_cstr(), hicc::cstr!("ab"));
/// ```
pub fn pop_back(&mut self) {
if !self.is_empty() {
self._pop_back();
}
}
#[cpp(method = "void pop_back()")]
fn _pop_back(&mut self);
/// ```
/// use hicc_std::string;
/// let mut s1 = string::from(hicc::cstr!("abc"));
/// let mut s2 = string::from(hicc::cstr!("de"));
/// s1.swap(&mut s2);
/// assert_eq!(s1.as_cstr(), hicc::cstr!("de"));
/// assert_eq!(s2.as_cstr(), hicc::cstr!("abc"));
/// ```
#[cpp(method = "void swap(Self&)")]
pub fn swap(&mut self, other: &mut Self);
/// ```
/// use hicc_std::string;
/// let s = string::from(hicc::cstr!("abc"));
/// assert_eq!(s.get(0), Some(&(b'a' as i8)));
/// assert_eq!(s.get(3), None);
/// ```
pub fn get(&self, pos: usize) -> Option<CharT::OutputRef<'_>> {
if pos < self.size() {
return Some(self._get(pos));
}
None
}
#[cpp(method = "const CharT& at(size_t) const")]
fn _get(&self, pos: usize) -> &CharT;
/// ```
/// use hicc_std::string;
/// let mut s = string::from(hicc::cstr!("abc"));
/// assert!(s.get_mut(0).is_some());
/// assert_eq!(*s.get_mut(0).unwrap(), b'a' as i8);
/// assert_eq!(s.get(3), None);
/// ```
pub fn get_mut(&mut self, pos: usize) -> Option<CharT::OutputRefMut<'_>> {
if pos < self.size() {
return Some(self._get_mut(pos));
}
None
}
#[cpp(method = "CharT& at(size_t)")]
fn _get_mut(&mut self, pos: usize) -> &mut CharT;
}
/// 对应`std::string`
#[allow(non_camel_case_types)]
pub type string = basic_string<hicc::Pod<i8>>;
/// 对应`std::u16string`
#[allow(non_camel_case_types)]
pub type u16string = basic_string<hicc::Pod<i16>>;
/// 对应`std::u32string`
#[allow(non_camel_case_types)]
pub type u32string = basic_string<hicc::Pod<i32>>;
}
unsafe impl<CharT: hicc::AbiType + Sync> Send for basic_string<CharT> {}
unsafe impl<CharT: hicc::AbiType + Sync> Sync for basic_string<CharT> {}
impl<T: Sized + 'static> basic_string<hicc::Pod<T>> {
/// ```
/// use hicc_std::string;
/// let mut s = string::with_cstr(hicc::cstr!("bcd"));
/// assert_eq!(s.as_slice(), &[b'b' as i8, b'c' as i8, b'd' as i8]);
/// ```
pub fn as_slice(&self) -> &[T] {
let cstr = self.c_str();
let size = self.size();
unsafe { slice::from_raw_parts(cstr, size) }
}
/// ```
/// use hicc_std::string;
/// let mut s = string::with_cstr(hicc::cstr!("abc"));
/// s.as_slice_mut().iter_mut().for_each(|mut c| { *c += 1; });
/// assert_eq!(s.as_slice(), &[b'b' as i8, b'c' as i8, b'd' as i8]);
/// ```
pub fn as_slice_mut(&mut self) -> &mut [T] {
let cstr = self.c_str();
let size = self.size();
unsafe { slice::from_raw_parts_mut(cstr.cast_mut(), size) }
}
}
impl<T: hicc::AbiType> PartialEq for basic_string<T> {
fn eq(&self, other: &Self) -> bool {
self.compare(other) == 0
}
}
impl<T: hicc::AbiType> PartialOrd for basic_string<T> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match self.compare(other) {
0 => Some(Ordering::Equal),
1.. => Some(Ordering::Greater),
_ => Some(Ordering::Less),
}
}
}
impl From<&CStr> for string {
fn from(s: &CStr) -> Self {
Self::with_cstr(s)
}
}
impl Default for string {
fn default() -> Self {
Self::new()
}
}
impl Default for u16string {
fn default() -> Self {
Self::new()
}
}
impl Default for u32string {
fn default() -> Self {
Self::new()
}
}
hicc::import_lib! {
#![link_name = "hicc_std_string"]
class string;
class u16string;
class u32string;
impl string {
#[cpp(func = "std::unique_ptr<std::string> hicc::make_unique<std::string>()")]
pub fn new() -> Self;
#[cpp(func = "std::unique_ptr<std::string> hicc::make_unique<std::string, const char*>(const char* &&)")]
pub fn with_cstr(s: &CStr) -> Self;
#[cpp(func = "std::unique_ptr<std::string> hicc::make_unique<std::string, const char*, size_t>(const char* &&, size_t&&)")]
pub unsafe fn with_cbuf(s: *const u8, len: usize) -> Self;
pub fn with_buf(b: &[u8]) -> Self {
unsafe { Self::with_cbuf(b.as_ptr(), b.len()) }
}
pub fn as_buf(&self) -> &[u8] {
unsafe { slice::from_raw_parts(self.c_str() as *const u8, self.size()) }
}
pub fn as_cstr(&self) -> &CStr {
unsafe { CStr::from_ptr(self.c_str()) }
}
}
#[inline(always)]
pub fn string_new() -> string {
string::new()
}
#[inline(always)]
pub fn string_with_cstr(s: *const i8) -> string {
let cs: &CStr = unsafe { CStr::from_ptr(s) };
string::with_cstr(cs)
}
#[inline(always)]
pub unsafe fn string_with_buf(s: *const u8, len: usize) -> string {
unsafe { string::with_cbuf(s, len) }
}
impl u16string {
#[cpp(func = "std::unique_ptr<std::u16string> hicc::make_unique<std::u16string>()")]
pub fn new() -> Self;
#[cpp(func = "std::unique_ptr<std::u16string> hicc::make_unique<std::u16string, const char16_t*, size_t>(const char16_t* &&, size_t&&)")]
pub unsafe fn with_cbuf(s: *const u16, len: usize) -> Self;
pub fn with_buf(b: &[u16]) -> Self {
unsafe { Self::with_cbuf(b.as_ptr(), b.len()) }
}
pub fn as_buf(&self) -> &[u16] {
unsafe { slice::from_raw_parts(self.c_str() as *const u16, self.size()) }
}
}
#[inline(always)]
pub fn u16string_new() -> u16string {
u16string::new()
}
#[inline(always)]
pub unsafe fn u16string_with_buf(s: *const u16, len: usize) -> u16string {
unsafe { u16string::with_cbuf(s, len) }
}
impl u32string {
#[cpp(func = "std::unique_ptr<std::u32string> hicc::make_unique<std::u32string>()")]
pub fn new() -> Self;
#[cpp(func = "std::unique_ptr<std::u32string> hicc::make_unique<std::u32string, const char32_t*, size_t>(const char32_t* &&, size_t&&)")]
pub unsafe fn with_cbuf(s: *const u32, len: usize) -> Self;
pub fn with_buf(b: &[u32]) -> Self {
unsafe { Self::with_cbuf(b.as_ptr(), b.len()) }
}
pub fn as_buf(&self) -> &[u32] {
unsafe { slice::from_raw_parts(self.c_str() as *const u32, self.size()) }
}
}
#[inline(always)]
pub fn u32string_new() -> u32string {
u32string::new()
}
#[inline(always)]
pub unsafe fn u32string_with_buf(s: *const u32, len: usize) -> u32string {
unsafe { u32string::with_cbuf(s, len) }
}
}