Comments (4)
Hi! I'm not sure what exactly do you mean. The code that you have posted seems to work, and expands to this:
#[inline(always)]
pub fn leading_ones(&self) -> u32 {
match self {
WeakRenderObject::RenderBox(o) => o,
WeakRenderObject::RenderSliver(o) => o,
WeakRenderObject::RenderView(o) => o,
}.leading_ones()
}
Is there something problematic with this?
from rust-delegate.
pub enum WeakRenderObject {
RenderBox(WeakRenderBox),
RenderSliver(WeakRenderSliver),
RenderView(WeakRenderView),
}
struct WeakRenderBox;
struct WeakRenderSliver;
struct WeakRenderView;
WeakRenderBox
WeakRenderSliver
WeakRenderView
are of different types. The match
expr returns different types, thus compiles error.
from rust-delegate.
I see. I'm not sure what could be the ideal way to enable this use-case though 🤔 In theory, there could be some placeholder value in the target expression and the delegation macro would replace that placeholder, like this:
impl WeakRenderObject {
delegate::delegate!(to match self {
WeakRenderObject::RenderBox(o) => o.$delegate,
WeakRenderObject::RenderSliver(o) => o.$delegate,
WeakRenderObject::RenderView(o) => o.$delegate,
} {
pub fn is_alive(&self) -> bool;
});
}
but I'm not sure if I can parse the code well enough so that I can find all of the placeholders. I'll try.
from rust-delegate.
Published v0.8.0
with this feature. Thank you very much!
from rust-delegate.
Related Issues (20)
- 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
- 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
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.