#string #third

string

A UTF-8 encoded string with configurable byte storage

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

#108 in Data structures

Download history 12387/week @ 2025-01-28 39106/week @ 2025-02-04 9921/week @ 2025-02-11 9608/week @ 2025-02-18 11817/week @ 2025-02-25 11747/week @ 2025-03-04 12705/week @ 2025-03-11 12895/week @ 2025-03-18 12264/week @ 2025-03-25 11828/week @ 2025-04-01 13683/week @ 2025-04-08 11234/week @ 2025-04-15 13051/week @ 2025-04-22 14093/week @ 2025-04-29 11587/week @ 2025-05-06 12949/week @ 2025-05-13

53,420 downloads per month
Used in 1,158 crates (via twitter-stream)

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

~235KB