Giter Club home page Giter Club logo

Comments (4)

weiznich avatar weiznich commented on August 19, 2024

This is essentially a duplicate of #23

As explained there this is a limitation of the current implementation of async in rustc, which means we cannot do much to improve the situation there as long as there are not substantial improvements on the language/compiler side. As for the error message: Yes that one is not great, but again: It's something that comes from rustc, so please report this in their repository. They care for such bad error messages and that's a quite general case here.

As a workaround: Your callback needs to own all relevant values. Use something like

let user: User = conn
        .transaction(move |conn| Box::pin(async move { users::table.find(user_id).first(conn).await }))
        .await?;

Closed as this is not actionable from our side.

from diesel_async.

Tuetuopay avatar Tuetuopay commented on August 19, 2024

Thanks. I did not think to check the GH discussions, only the issues, sorry.

Sadly the workaround is ... not that possible as I'm handed borrowed data directly. I'd need to clone it, which is not ideal at all. Oh well, that's what I'm getting for being on the bleeding edge 😄

from diesel_async.

weiznich avatar weiznich commented on August 19, 2024

I'd need to clone it, which is not ideal at all.

I fear cloning stuff is currently the only possible solution. I'm happy to be proven wrong here, but I just do not see any other option to write such an API at all.

from diesel_async.

Tuetuopay avatar Tuetuopay commented on August 19, 2024

Yep, in this case I cannot avoid cloning as I'm passed references. In the owned case, the usual lifetime joker that is Arc is a solution though.

from diesel_async.

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.