Code Monkey home page Code Monkey logo

Comments (3)

Majored avatar Majored commented on July 17, 2024

There's no actual explicit 'static lifetime, but likely an implicit one due to being placed on the heap (Arc/Box). Heck, even my own example for the read::fs module puts it on the heap.

So given that, and the fact that the whole point of read::fs is to be parallel, making it an owned string is really the only option I can see as well. I could use a Cow, but to make that work, we'd have to make the caller pass a pre-constructed Cow and decide whether it be borrowed or owned. That doesn't feel like a good API design to me.

I'll get this done when I next go to work on this crate. ๐Ÿ‘

Edit: Though, I guess I could just have two different constructors that handle the Cow construction as well for you. That seems quite a good idea actually.

from rs-async-zip.

softprops avatar softprops commented on July 17, 2024

Thanks. For what itโ€™s worth itโ€™s less the lifetime constraints of this crate than it is the async ecosystem.

Following the example code, functions like tokio::spawn require static lifetimes

handles.push(tokio::spawn(async move {

from rs-async-zip.

Majored avatar Majored commented on July 17, 2024

Actually, coming back to this, I'm going to make it an owned string as you suggest.
No point in adding the complexity with Cow & two different constructors for the sake of a single allocation.

from rs-async-zip.

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.