Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension via vtable with dyn #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Extension via vtable with dyn #4

wants to merge 1 commit into from

Conversation

kchibisov
Copy link
Member

cc @madsmtm @daxpedda

That's approach with &mut dyn, it does require as_any method implemented by the user, but I guess it's fine?

@@ -35,6 +37,8 @@ pub trait Window: HasWindowHandle + HasRawWindowHandle05 {
fn current_monitor(&self) -> Option<MonitorId>;

fn primary_monitor(&self) -> Option<MonitorId>;

fn as_any(&mut self) -> &mut dyn Any;
Copy link
Member

Choose a reason for hiding this comment

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

This is not possible?

Suggested change
fn as_any(&mut self) -> &mut dyn Any;
fn as_any(&mut self) -> &mut dyn Any {
self
}

What if we add Window: Any to the trait itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, it's not, because it'll require sized and it's not object safe, etc. it's not really a big issue though.

Copy link
Member Author

Choose a reason for hiding this comment

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

You can try to pull my code and play with it, but it wasn't really working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants