Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

123
FlexStr – A flexible, simple to use, immutable, clone-efficient String replacement for Rust. It unifies literals, inlined, and heap allocated strings into a single type.
Post Body

Github | Crates.io | Docs.rs | Preliminary Benchmarks

I created this because I found myself cloning String all the time while working on a large project. Essentially, I had several HashMaps and no simple way to borrow the String for the lifetime I needed so ended up with several clones. It seemed silly to me to be copying string data over and over when most strings are immutable.

Additionally, I wanted a type that would combine string literals with heap based strings as I found myself often having struct fields that could be a literal or a heap allocated String. I ended up allocating in several cases for something that was already static.

The inline string type is due to needing some very short string creation from primitives and it seemed wasteful to do a heap allocation.

I was kinda suprised nobody had created a string type like this yet. (UPDATE: This is very similar to "kstring" crate I just learned). There were several candidates for inline strings, some ref counted strings, but I couldn't find a string crate that did all three as a single combined type.

EDIT: This crate is considered "beta" - it has 88% test coverage atm, but only some light real world usage in my hobby projects. Extra testing and feedback is welcome, but it may not be ready for hardcore production just yet.

Author
Account Strength
90%
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
2,263
Link Karma
352
Comment Karma
1,891
Profile updated: 22 hours ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago