{"id":18016909,"url":"https://github.com/fitzgen/inlinable_string","last_synced_at":"2025-04-05T22:06:54.155Z","repository":{"id":2705248,"uuid":"47223972","full_name":"fitzgen/inlinable_string","owner":"fitzgen","description":"An owned, grow-able UTF-8 string that stores small strings inline and avoids heap-allocation.","archived":false,"fork":false,"pushed_at":"2022-01-04T08:43:52.000Z","size":734,"stargazers_count":68,"open_issues_count":5,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T21:05:22.105Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://fitzgen.github.io/inlinable_string/inlinable_string/index.html","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fitzgen.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2015-12-01T23:29:33.000Z","updated_at":"2024-11-16T11:07:02.000Z","dependencies_parsed_at":"2022-08-06T12:31:06.686Z","dependency_job_id":null,"html_url":"https://github.com/fitzgen/inlinable_string","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/fitzgen%2Finlinable_string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Finlinable_string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Finlinable_string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Finlinable_string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fitzgen","download_url":"https://codeload.github.com/fitzgen/inlinable_string/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406088,"owners_count":20933803,"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":[],"created_at":"2024-10-30T04:19:40.251Z","updated_at":"2025-04-05T22:06:54.119Z","avatar_url":"https://github.com/fitzgen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `inlinable_string`\n\n[![](http://meritbadge.herokuapp.com/inlinable_string)![](https://img.shields.io/crates/d/inlinable_string.png)](https://crates.io/crates/inlinable_string)\n\n[![Build Status](https://travis-ci.org/fitzgen/inlinable_string.png?branch=master)](https://travis-ci.org/fitzgen/inlinable_string)\n\n[![Coverage Status](https://coveralls.io/repos/fitzgen/inlinable_string/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/fitzgen/inlinable_string?branch=master)\n\nThe `inlinable_string` crate provides the `InlinableString` type \u0026mdash; an\nowned, grow-able UTF-8 string that stores small strings inline and avoids\nheap-allocation \u0026mdash; and the `StringExt` trait which abstracts string\noperations over both `std::string::String` and `InlinableString` (or even your\nown custom string type).\n\n`StringExt`'s API is mostly identical to `std::string::String`; unstable and\ndeprecated methods are not included. A `StringExt` implementation is provided\nfor both `std::string::String` and `InlinableString`. This enables\n`InlinableString` to generally work as a drop-in replacement for\n`std::string::String` and `\u0026StringExt` to work with references to either type.\n\n## But is it actually faster than using `std::string::String`?\n\nHere are some current (micro)benchmark results. I encourage you to verify them\nyourself by running `cargo bench --feature nightly` with a nightly Rust! I am\nalso very open to adding more realistic and representative benchmarks! Share\nsome ideas with me!\n\nConstructing from a large `\u0026str`:\n\n```\ntest benches::bench_inlinable_string_from_large                ... bench:          32 ns/iter (+/- 6)\ntest benches::bench_std_string_from_large                      ... bench:          31 ns/iter (+/- 10)\n```\n\nConstructing from a small `\u0026str`:\n\n```\ntest benches::bench_inlinable_string_from_small                ... bench:           1 ns/iter (+/- 0)\ntest benches::bench_std_string_from_small                      ... bench:          26 ns/iter (+/- 14)\n```\n\nPushing a large `\u0026str` onto an empty string:\n\n```\ntest benches::bench_inlinable_string_push_str_large_onto_empty ... bench:          37 ns/iter (+/- 12)\ntest benches::bench_std_string_push_str_large_onto_empty       ... bench:          30 ns/iter (+/- 9)\n```\n\nPushing a small `\u0026str` onto an empty string:\n\n```\ntest benches::bench_inlinable_string_push_str_small_onto_empty ... bench:          11 ns/iter (+/- 4)\ntest benches::bench_std_string_push_str_small_onto_empty       ... bench:          23 ns/iter (+/- 10)\n```\n\nPushing a large `\u0026str` onto a large string:\n\n```\ntest benches::bench_inlinable_string_push_str_large_onto_large ... bench:          80 ns/iter (+/- 24)\ntest benches::bench_std_string_push_str_large_onto_large       ... bench:          78 ns/iter (+/- 23)\n```\n\nPushing a small `\u0026str` onto a small string:\n\n```\ntest benches::bench_inlinable_string_push_str_small_onto_small ... bench:          17 ns/iter (+/- 6)\ntest benches::bench_std_string_push_str_small_onto_small       ... bench:          60 ns/iter (+/- 15)\n```\n\nTLDR: If your string's size tends to stay within `INLINE_STRING_CAPACITY`, then\n`InlinableString` is much faster. Crossing the threshold and forcing a promotion\nfrom inline storage to heap allocation will slow it down more than\n`std::string::String` and you can see the expected drop off in such cases, but\nthat is generally a one time cost. Once the strings are already larger than\n`INLINE_STRING_CAPACITY`, then the performance difference is\nnegligible. However, take all this with a grain of salt! These are very micro\nbenchmarks and your (hashtag) Real World workload may differ greatly!\n\n## Install\n\nEither\n\n    $ cargo add inlinable_string\n\nor add this to your `Cargo.toml`:\n\n    [dependencies]\n    inlinable_string = \"0.1.0\"\n\n## Documentation\n\n[Documentation](http://fitzgen.github.io/inlinable_string/inlinable_string/index.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Finlinable_string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffitzgen%2Finlinable_string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Finlinable_string/lists"}