{"id":16883911,"url":"https://github.com/zbraniecki/tinystr","last_synced_at":"2025-04-07T15:07:53.730Z","repository":{"id":35056863,"uuid":"201562324","full_name":"zbraniecki/tinystr","owner":"zbraniecki","description":"A small ASCII-only bounded length string representation.","archived":false,"fork":false,"pushed_at":"2022-02-07T18:49:27.000Z","size":152,"stargazers_count":59,"open_issues_count":3,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-31T12:08:44.107Z","etag":null,"topics":["library","optimization","performance","rust","string","structures"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zbraniecki.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-10T01:18:27.000Z","updated_at":"2025-03-21T00:17:01.000Z","dependencies_parsed_at":"2022-08-08T04:15:36.047Z","dependency_job_id":null,"html_url":"https://github.com/zbraniecki/tinystr","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbraniecki%2Ftinystr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbraniecki%2Ftinystr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbraniecki%2Ftinystr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbraniecki%2Ftinystr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zbraniecki","download_url":"https://codeload.github.com/zbraniecki/tinystr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675597,"owners_count":20977376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","optimization","performance","rust","string","structures"],"created_at":"2024-10-13T16:14:40.580Z","updated_at":"2025-04-07T15:07:53.712Z","avatar_url":"https://github.com/zbraniecki.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tinystr [![crates.io](https://img.shields.io/crates/v/tinystr.svg)](https://crates.io/crates/tinystr) [![Build Status](https://travis-ci.org/zbraniecki/tinystr.svg?branch=master)](https://travis-ci.org/zbraniecki/tinystr) [![Coverage Status](https://coveralls.io/repos/github/zbraniecki/tinystr/badge.svg?branch=master)](https://coveralls.io/github/zbraniecki/tinystr?branch=master)\n\n`tinystr` is a small ASCII-only bounded length string representation.\n\nUsage\n-----\n\n```rust\nuse tinystr::{TinyStr4, TinyStr8, TinyStr16, TinyStrAuto};\n\nfn main() {\n    let s1: TinyStr4 = \"tEsT\".parse()\n        .expect(\"Failed to parse.\");\n\n    assert_eq!(s1, \"tEsT\");\n    assert_eq!(s1.to_ascii_uppercase(), \"TEST\");\n    assert_eq!(s1.to_ascii_lowercase(), \"test\");\n    assert_eq!(s1.to_ascii_titlecase(), \"Test\");\n    assert_eq!(s1.is_ascii_alphanumeric(), true);\n\n    let s2: TinyStr8 = \"New York\".parse()\n        .expect(\"Failed to parse.\");\n\n    assert_eq!(s2, \"New York\");\n    assert_eq!(s2.to_ascii_uppercase(), \"NEW YORK\");\n    assert_eq!(s2.to_ascii_lowercase(), \"new york\");\n    assert_eq!(s2.to_ascii_titlecase(), \"New york\");\n    assert_eq!(s2.is_ascii_alphanumeric(), false);\n\n    let s3: TinyStr16 = \"metaMoRphosis123\".parse()\n        .expect(\"Failed to parse.\");\n\n    assert_eq!(s3, \"metaMoRphosis123\");\n    assert_eq!(s3.to_ascii_uppercase(), \"METAMORPHOSIS123\");\n    assert_eq!(s3.to_ascii_lowercase(), \"metamorphosis123\");\n    assert_eq!(s3.to_ascii_titlecase(), \"Metamorphosis123\");\n    assert_eq!(s3.is_ascii_alphanumeric(), true);\n\n    let s4: TinyStrAuto = \"shortNoAlloc\".parse().unwrap();\n    assert!(matches!(s4, TinyStrAuto::Tiny { .. }));\n    assert_eq!(s4, \"shortNoAlloc\");\n\n    let s5: TinyStrAuto = \"longFallbackToHeap\".parse().unwrap();\n    assert!(matches!(s4, TinyStrAuto::Heap { .. }));\n    assert_eq!(s4, \"shortNoAlloc\");\n}\n```\n\nDetails\n-------\n\nThe crate provides three structs and an enum:\n * `TinyStr4` an ASCII-only string limited to 4 characters.\n * `TinyStr8` an ASCII-only string limited to 8 characters.\n * `TinyStr16` an ASCII-only string limited to 16 characters.\n * `TinyStrAuto` (enum):\n   * `Tiny` when the string is 16 characters or less.\n   * `Heap` when the string is 17 or more characters.\n\nThe structs stores the characters as `u32`/`u64`/`u128` and uses bitmasking to provide basic string manipulation operations:\n * is_ascii_numeric\n * is_ascii_alphabetic\n * is_ascii_alphanumeric\n * to_ascii_lowercase\n * to_ascii_uppercase\n * to_ascii_titlecase\n * PartialEq\n\n`TinyStrAuto` stores the string as a TinyStr16 when it is short enough, or else falls back to a standard `String`. You should use TinyStrAuto when you expect most strings to be 16 characters or smaller, but occasionally you receive one that exceeds that length. Unlike the structs, `TinyStrAuto` does not implement `Copy`.\n\nThis set is sufficient for certain classes of uses such as `unic-langid` libraries.\n\nno_std\n------\n\nDisable the `std` feature of this crate to make it `#[no_std]`. Doing so disables `TinyStrAuto`. You\ncan re-enable `TinyStrAuto` in `#[no_std]` mode by enabling the `alloc` feature.\n\nPerformance\n-----------\n\nFor those uses, TinyStr provides [performance characteristics](https://github.com/zbraniecki/tinystr/wiki/Performance) much better than the regular `String`.\n\nStatus\n------\n\nThe crate is fully functional and ready to be used in production.\nThe capabilities can be extended.\n\n#### License\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\u003c/sup\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbraniecki%2Ftinystr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzbraniecki%2Ftinystr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbraniecki%2Ftinystr/lists"}