Giter VIP home page Giter VIP logo

Comments (5)

Kobzol avatar Kobzol commented on August 15, 2024

Hi! That seems like a useful use-case. Please try this PR: #39 with this code:

impl SharedUserRepo {
  delegate! {
    to self.0.lock().await {
     #[await(false)]
     async fn add() { /* ... */ }
     #[await(false)]
     async fn del() { /* ... */ }
    }
  }
}

You can use the code from the PR with this dependency specification in Cargo.toml:

[dependencies]
delegate = { git = "https://github.com/kobzol/rust-delegate", branch = "await-attribute" }

from rust-delegate.

kyku avatar kyku commented on August 15, 2024

Works for me ™ ;-) Thanks

from rust-delegate.

Kobzol avatar Kobzol commented on August 15, 2024

Great! I published a new version (0.6.2) with the attribute.

from rust-delegate.

kyku avatar kyku commented on August 15, 2024

Would it be possible to support this attribute before the to block, like in:

delegate! {
  #[await(false)]
  to self.0.lock().await {
     async fn f1();
     // ...
     async fn fn();
  }
}

This would be equivalent of placing #[await(false)] before every fX() inside of the block.

from rust-delegate.

Kobzol avatar Kobzol commented on August 15, 2024

I'll think about it. It definitely seems useful, but I don't want to enable it only for #[await], if attributes are enabled on top of to, it should also work for other things, at least #[into] (not sure if #[call] makes sense here). And if we enable the attribute for some to block, we then need an ability to turn it off for individual items. This can already be done with #[await], but not for #[into], so I would also need to make some changes there, hopefully in a backwards compatible way.

It will require some refactoring and I don't know how difficult it will be to parse. I'll experiment with it.

from rust-delegate.

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.