Comments (5)
I changed it to use
and I like how it reads, but if I'm not missing anything it seems that it cannot actually be used, because it's an actual keyword and when I parse the attribute, it expects a path after use
and therefore I cannot use it as use(name)
. Unless we want to write something like r#use
:-)
call
doesn't have this problem, since it's not a keyword and I think that it's more explicit, even though we actually generate #[inline(always)]
by default, so the call might only be there at compile time :)
Also when the user specifies inline
manually, like this:
#[inline(always)]
#[call(method)]
...
it reads a bit weird, but it's a small detail I suppose.
Another thing that came up is wrap
, but it doesn't have a well established meaning in this crate (and in general it's a very overloaded term), so that's probably worse than call
.
from rust-delegate.
I like as
, but I see two problems with it:
- In my opinion the name
as
implies that it will generate code like this:
#[as(len)]
pub fn size(&self) -> usize;
v
pub fn len(&self) -> usize { self.inner.size() }
But in the current implementation, the renaming order is reversed, i.e. it would actually generate this:
pub fn size(&self) -> usize { self.inner.len() }
I looked at the implementation briefly and it's much easier for me to change the name in this direction. I will try to modify it so that I could also use the other direction, but I'm not sure if it's possible to do so easily.
- When the user writes
pub fn size(&self) -> usize;
, I think that it is more natural that the actual method will have exactly this signature, i.e. I think it's better if the attribute changes the underlying method call and not the signature.as
sounds like you are changing the signature (export this functionas len
).
If we keep the current implementation, we have to use a name that obviously changes the called method and not the signature. call(len)
or use(len)
seem like good alternatives to me.
from rust-delegate.
@Kobzol
Yes, I agree, I did not mean to suggest swapping the order of the callee and caller (and I don't think we should support this swapping in any way, to avoid confusion).
I also agree that as
could be misinterpreted to mean that.
Actually, I hadn't thought of use(len)
, but it looks like the best option to me! :)
from rust-delegate.
What about target or using
from rust-delegate.
I think call
is a good choice!
from rust-delegate.
Related Issues (20)
- Suggestion: Allow ignoring return value of target method HOT 9
- Suggestion: Shorter keyword than `target` HOT 1
- Suggestion: Allow non-field targets HOT 3
- Doc: rewrite README HOT 1
- New Release Please HOT 2
- Delegate target cannot come from macro expansion
- Nested proc attributes HOT 1
- Arbitrary inner field expressions HOT 2
- self as target doesn't seem to work HOT 9
- is it possible to delegate all methods? HOT 2
- 0.5.0 fails to compile
- Delegate with additional arguments
- Transfer ownership! HOT 3
- Bridging sync to async gap with delegate HOT 5
- 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
- Delegation to members of members? HOT 2
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.