Giter VIP home page Giter VIP logo

Comments (6)

ia0 avatar ia0 commented on July 2, 2024

Hi, you should be able to use this function depending on your use-case. Could you tell me a bit more if that function doesn't satisfy your need? Thanks!

from data-encoding.

L-as avatar L-as commented on July 2, 2024

Sorry for not being clear enough: I am wondering if there is a way to write into a &mut String without allocating an intermediary String. Thanks.

from data-encoding.

ia0 avatar ia0 commented on July 2, 2024

I see, indeed this is a missing feature. If I understand correctly, you are suggesting adding something like:

/// Appends the encoding of `input` to `output`
pub fn encode_mut_string(&self, input: &[u8], output: &mut String)

This looks like a useful function. I will need to think a bit about the naming and see if I don't merge it with encode_mut using a trait for the supported output types.

When would you need such function?

In the meantime, I guess you already use something similar to this as a workaround.

from data-encoding.

L-as avatar L-as commented on July 2, 2024

I am building a String which I then use elsewhere. I could make it a Vec instead, but that would mean I have to check that it's correct UTF-8 later, OR I could just use your workaround (which I am not using, so thanks!). Thanks for the help, it's a really nice crate.

from data-encoding.

ia0 avatar ia0 commented on July 2, 2024

No problem, thanks! I'll take a look at it when I get time.

Indeed, users should not have to use Vec instead of String for output of encoding functions. In particular, data-encoding provides the guarantee that output is ASCII, so the unsafe code should be hidden in the library so that users can use a safe API.

from data-encoding.

ia0 avatar ia0 commented on July 2, 2024

data-encoding 2.3.0 has been released and provides an encode_append function as requested. If anything is wrong, please reopen the issue. Thanks for the initial feedback!

from data-encoding.

Related Issues (20)

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.