Comments (5)
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.
Works for me ™ ;-) Thanks
from rust-delegate.
Great! I published a new version (0.6.2
) with the attribute.
from rust-delegate.
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.
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)
- Transfer ownership! HOT 3
- Allow #[from] and #[into] annotations, pattern-matching or even arbitrary transformation functions for delegated arguments HOT 10
- allow #[try_from] and #[try_into] HOT 8
- Is delegating to enum in the target range HOT 4
- Compatability with async_trait HOT 2
- Just unwrap HOT 3
- Assign Return Value Of Delegated Calls To Delegated Field HOT 7
- Add attribute to the return value of all methods HOT 4
- Add support support for qualified calls HOT 6
- Delegate to Self HOT 1
- transform the return value of `Result` and `Option` type HOT 8
- New release? HOT 1
- Change default inlining mode
- `no_std` support HOT 3
- Possible to support delegation of Constructors? Fuctions returning `Self` and `Result<Self, SomeErr>`? HOT 4
- Re-use documentation from delegated method HOT 2
- Support for delagating to enum variants with different inner type and `#[into]` modifier. HOT 6
- forwarding docs HOT 1
- Suggestion: Delegate associated functions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-delegate.