polazarus / hipstr Goto Github PK
View Code? Open in Web Editor NEWYet another string type for Rust
License: Apache License 2.0
Yet another string type for Rust
License: Apache License 2.0
Arc<str>
compares pointers first which normal reference equality checks do not perform.
See https://htmlpreview.github.io/?https://github.com/epage/string-benchmarks-rs/blob/master/runs/2023-10-10/eq/report/index.html for a benchmark showcasing the behavior from this
https://docs.rs/hipstr/0.4.0/hipstr/bytes/struct.HipByt.html#method.concat
If I have a [&str; 5]
this would use 80 bytes to represent the string data correct? But with a HipStr
if the actual data were 23 bytes or less I could compose that representation as a single HipStr
and avoid allocating a new String
?
I'm not sure if that would be any different than just creating a new HipStr
and doing push_str()
?:
let iter = ["key".as_bytes(), "value".as_bytes()];
iter.fold(HipByt::new(), |mut s, v| { s.push_slice(v); s })
let iter = ["key", "value"].into_iter();
iter.fold(HipStr::new(), |mut s, v| { s.push_str(v); s })
I've seen various methods for HipStr
and HipByt
that will output their type from a slice of the existing data, but not much for constructing the type from multiples of the type (or &str
/ &[u8]
).
let parts = [key, "=\"", value, "\""];
// key="value"
let formatted = parts.concat();
Would it be worthwhile for HipStr
and HipByt
to support concat()
to create an inline value more easily from multiple values?
In my case, I have a HashMap collection of KV pairs that I iterate through to create key="value"
sequences, then the iterator composes those into a single String
output.
That is fast with references (&str
or &HipStr
), and from what I understand this isn't something HipStr
could improve on? So constructing a HipStr
from an array of &str
/ &HipStr
doesn't appear helpful due to the extra allocations/operations required?
How to get owned HipStr
when using lines
or split_whitespace
on original HipStr
?
Currently, lines
returns &str
, it causes HipStr
to make a copy of &str
. I want a slice of the original data.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.