hipstr is back with a fresh 0.7.0 version

57 points polazarusphd 3 comments

Rust has way too many string types already: str, String, but also Cow<str>, OsStr, OsString, Path, PathBuf, etc. And yet, you may need hipstr:

use hipstr::HipStr;

let s = HipStr::from("Lorem ipsum dolor sit amet");
let clone = s.clone(); // no copy

let greetings = "Hello John! Welcome to ";
let mut greetings = HipStr::borrowed(greetings); // no copy
let user_name = greetings.slice(6..10); // still no copy
greetings.push("Earth"); // automatically realloc

Under the hood, hipstr uses three different representations:

  • One for borrows,
  • One for short inline strings,
  • One for reference-counted smart pointers.

And all on three little machine words (like String) with a niche (Option<HipStr> is the same size as HipStr).

hipstr comes from an already long tradition in Rust: writing new string types for fun and near-zero profit: arcstr, flexstr, compact_str, etc. The README covers the main differences with most of them.

Obviously, hipstr is no silver bullet 😢. In fact, in some use cases, blind use may lead to memory contention. So you may still need other string types…

What's new in v0.7.0?

  • Remove some dependencies: back to zero dependency by default
  • Improve serde performances (thx dsherret)
  • Add borsh support
  • Simplify internals
  • Fix wasm compilation when serde support is enabled (thx dsherret)
  • Fix path comparison semantics

And still near-full line coverage!

Check it out on crates.io: https://crates.io/crates/hipstr

And on GitHub: https://github.com/polazarus/hipstr