4 stable releases
1.1.1 | Jan 13, 2023 |
---|---|
1.1.0 | Oct 25, 2022 |
1.0.1 | Oct 21, 2022 |
#1646 in Text processing
55 downloads per month
Used in 2 crates
10KB
183 lines
StringBox
Allows developers to create Rust String
from byte-string, utf-8 encoded C-string or wide-string.
Examples
From a not null-terminated byte-string:
let byte_string = vec![104u8, 101, 108, 108, 111];
let string = StringBox::from_byte_string(byte_string);
assert_eq!(string.to_string(), String::from("hello"));
From a null-terminated utf-8 string:
let utf8_string = vec![104u8, 101, 108, 108, 111, 0];
let string = StringBox::from_utf8_string(utf8_string.as_slice());
assert_eq!(string.to_string(), String::from("hello"));
Dependencies
~520KB