Skip to content

Use impl instead of ProtocolObject where possible - #517

Open
madsmtm wants to merge 2 commits into
mainfrom
minimize-use-of-protocolobject
Open

Use impl instead of ProtocolObject where possible#517
madsmtm wants to merge 2 commits into
mainfrom
minimize-use-of-protocolobject

Conversation

@madsmtm

@madsmtm madsmtm commented Sep 21, 2023

Copy link
Copy Markdown
Owner

Builds upon #516.

We now use &(impl MyProtocol + Message) instead of &ProtocolObject<dyn MyProtocol> as parameters to functions, this allows users to pass in their objects to these functions much more easily.

I'm not sure it's worth the tradeoff in code size though (since now a lot of methods are generic where they don't really have to be), will have to think about.

Alternative to #686 (that one is still strictly cleaner, but probably also not really possible in current Rust (?)).

@madsmtm madsmtm added enhancement New feature or request A-framework Affects the framework crates and the translator for them labels Sep 21, 2023
@madsmtm madsmtm added this to the Polish icrate milestone Sep 21, 2023
@madsmtm
madsmtm force-pushed the protocol-fixes branch 6 times, most recently from 2b57f62 to 1c663ba Compare December 3, 2023 08:11
Base automatically changed from protocol-fixes to master December 3, 2023 08:33
@madsmtm
madsmtm force-pushed the minimize-use-of-protocolobject branch from 392f711 to 3449797 Compare November 25, 2024 15:25
Comment on lines -79 to -80
let object = ProtocolObject::from_ref(&*delegate);
app.setDelegate(Some(object));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I've never used ::from_ref() for these before but always just object = delegate.as_ref() which is a bit more concise and also seemed to figure out.

@madsmtm madsmtm removed this from the Polish frameworks milestone Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-framework Affects the framework crates and the translator for them enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants