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

Add CastNone trait #843

Merged
merged 5 commits into from Dec 4, 2022
Merged

Add CastNone trait #843

merged 5 commits into from Dec 4, 2022

Conversation

ranfdev
Copy link
Member

@ranfdev ranfdev commented Dec 1, 2022

Closes #842

glib/src/object.rs Outdated Show resolved Hide resolved
glib/src/object.rs Outdated Show resolved Hide resolved
Co-authored-by: Bilal Elmoussaoui <belmouss@redhat.com>
@sdroege
Copy link
Member

sdroege commented Dec 2, 2022

I don't like the API but if people think this is useful to have let's merge it. @bilelmoussaoui @GuillaumeGomez?

@bilelmoussaoui
Copy link
Member

I don't like the API but if people think this is useful to have let's merge it. @bilelmoussaoui @GuillaumeGomez?

I think the use case for this API would be mostly GTK and libraries building on top of it as mentioned on the Matrix channel. I would suggest adding a warning to not go through this API unless downcasting/upcasting to the wrong type is a programmer error and the fallback shouldn't handled in that case.

glib/src/object.rs Outdated Show resolved Hide resolved
@bilelmoussaoui bilelmoussaoui added the needs-backport PR needs backporting to the current stable branch label Dec 4, 2022
@bilelmoussaoui bilelmoussaoui merged commit 6961ee4 into gtk-rs:master Dec 4, 2022
bilelmoussaoui pushed a commit that referenced this pull request Dec 5, 2022
* Add CastNone trait

Closes #842

* Add CastNone to prelude, add dynamic_cast

* Add example for CastNone

* Describe type using turbofish op
@pbor pbor removed the needs-backport PR needs backporting to the current stable branch label Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] downcast/upcast on Option<Object>
4 participants