Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Bodil Stokke b98a0418fc
All checks were successful
Continuous Integration / Rustfmt (push) Successful in 54s
Continuous Integration / Miri (push) Successful in 2m42s
Continuous Integration / Check (push) Successful in 1m25s
Continuous Integration / Tests (push) Successful in 1m58s
Continuous Integration / no_std build (push) Successful in 45s
Continuous Integration / Clippy (push) Successful in 1m14s
Update repo URL.
2026-11-01 21:50:59 +00:00
.forgejo/workflows Forgejo CI workflow. 2026-11-01 21:02:16 +00:00
benches Update to Criterion 0.8. 2026-11-01 17:42:46 +00:00
fuzz Update to Rust 2024, with Clippy obeisance etc. 2026-10-29 20:52:24 +00:00
proptest-regressions Use a boxed string with a controlled layout to avoid bad assumptions. 2022-02-23 20:11:53 +00:00
src Update changelog for release. 2026-11-01 21:25:04 +00:00
.gitignore Make it so. 2020-05-15 21:39:20 +01:00
build.rs Update to Rust 2024, with Clippy obeisance etc. 2026-10-29 20:52:24 +00:00
Cargo.toml Update repo URL. 2026-11-01 21:50:59 +00:00
CHANGELOG.md chore: Release smartstring version 2.0.0 2026-11-01 21:32:23 +00:00
CODE_OF_CONDUCT.md Make it so. 2020-05-15 21:39:20 +01:00
LICENCE.md Make it so. 2020-05-15 21:39:20 +01:00
README.md Update changelog for release. 2026-11-01 21:25:04 +00:00
release.toml Update changelog for release. 2026-11-01 21:25:04 +00:00

smartstring

Compact inlined strings.

tl;dr

String type that's source compatible with std::string::String, uses exactly the same amount of space, doesn't heap allocate for short strings (up to 23 bytes on 64-bit archs) by storing them in the space a String would have taken up on the stack, making strings go faster overall.

Overview

This crate provides a wrapper for Rust's standard String which uses the space a String occupies on the stack to store inline string data, automatically promoting it to a String when it grows beyond the inline capacity. This has the advantage of avoiding heap allocations for short strings as well as improving performance thanks to keeping the strings on the stack.

This is all accomplished without the need for an external discriminant, so a SmartString is exactly the same size as a String on the stack, regardless of whether it's inlined or not. Converting a heap allocated SmartString into a String and vice versa is also a zero cost operation, as one will reuse the allocated memory of the other.

Documentation

Licence

Copyright 2020 Bodil Stokke

This software is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.