Coder Social home page Coder Social logo

hipstr's People

Contributors

polazarus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hipstr's Issues

Support `concat()` or similar?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.