9 releases

0.3.1 Sep 13, 2024
0.3.0 Dec 2, 2021
0.2.1 Jun 27, 2019
0.2.0 Mar 6, 2019
0.0.0 Jul 25, 2017

#105 in Data structures

Download history 16976/week @ 2025-11-10 25930/week @ 2025-11-17 16108/week @ 2025-11-24 14995/week @ 2025-12-01 33422/week @ 2025-12-08 15373/week @ 2025-12-15 12963/week @ 2025-12-22 11736/week @ 2025-12-29 13253/week @ 2026-01-05 13992/week @ 2026-01-12 17338/week @ 2026-01-19 15839/week @ 2026-01-26 16295/week @ 2026-02-02 11768/week @ 2026-02-09 18714/week @ 2026-02-16 22168/week @ 2026-02-23

70,828 downloads per month
Used in 1,145 crates (2 directly)

MIT license

13KB
178 lines

A UTF-8 encoded string with configurable byte storage.

This crate provides String, a type similar to its std counterpart, but with one significant difference: the underlying byte storage is configurable. In other words, String<T> is a marker type wrapping T, indicating that it represents a UTF-8 encoded string.

For example, one can represent small strings (stack allocated) by wrapping an array:

let s: String<[u8; 2]> = String::try_from([b'h', b'i']).unwrap();
assert_eq!(&s[..], "hi");

String

A UTF-8 encoded string with configurable byte storage.

Build Status License: MIT Crates.io Documentation

Usage

To use string, first add this to your Cargo.toml:

[dependencies]
string = "0.3.1"

Next, add this to your crate:

extern crate string;

use string::{String, TryFrom};

let s: String<[u8; 2]> = String::try_from([b'h', b'i']).unwrap();
assert_eq!(&s[..], "hi");

See documentation for more details.

Dependencies

~220KB