[][src]Crate tinystr

tinystr is a small ASCII-only bounded length string representation.

The crate is meant to be used for scenarios where one needs a fast and memory efficient way to store and manipulate short ASCII-only strings.

tinystr converts each string into an unsigned integer, and uses bitmasking to compare, convert cases and test for common characteristics of strings.

Example

use tinystr::{TinyStr4, TinyStr8};

fn main() {
    let s1: TinyStr4 = "tEsT".parse()
        .expect("Failed to parse.");

    assert_eq!(s1, "tEsT");
    assert_eq!(s1.to_ascii_uppercase(), "TEST");
    assert_eq!(s1.to_ascii_lowercase(), "test");
    assert_eq!(s1.to_ascii_titlecase(), "Test");
    assert_eq!(s1.is_ascii_alphanumeric(), true);

    let s2: TinyStr8 = "New York".parse()
        .expect("Failed to parse.");

    assert_eq!(s2, "New York");
    assert_eq!(s2.to_ascii_uppercase(), "NEW YORK");
    assert_eq!(s2.to_ascii_lowercase(), "new york");
    assert_eq!(s2.is_ascii_alphanumeric(), false);
}

Structs

TinyStr4

A tiny string that is from 1 to 4 non-NUL ASCII characters.

TinyStr8

A tiny string that is from 1 to 8 non-NUL ASCII characters.

TinyStr16

A tiny string that is from 1 to 16 non-NUL ASCII characters.

Enums

Error

Enum to store the various types of errors that can cause parsing a TinyStr to fail.