string-box

Crates.iostring-box
lib.rsstring-box
version1.1.1
sourcesrc
created_at2022-10-21 13:08:41.941512
updated_at2023-01-13 22:07:09.874897
descriptionCreate Rust string from UTF-8 string, byte string or wide string.
homepage
repositoryhttps://github.com/feenkcom/boxes-rs/tree/main/string-box
max_upload_size
id693586
size9,395
Aliaksei Syrel (syrel)

documentation

README

StringBox

Crates.io MIT licensed

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"));
Commit count: 0

cargo fmt