Crates.io | string-box |
lib.rs | string-box |
version | 1.1.1 |
source | src |
created_at | 2022-10-21 13:08:41.941512 |
updated_at | 2023-01-13 22:07:09.874897 |
description | Create Rust string from UTF-8 string, byte string or wide string. |
homepage | |
repository | https://github.com/feenkcom/boxes-rs/tree/main/string-box |
max_upload_size | |
id | 693586 |
size | 9,395 |
Allows developers to create Rust String
from byte-string, utf-8 encoded C-string or wide-string.
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"));