Skip to content

Automatically implement Upcast<Self> for all types #1247

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

Merged
merged 2 commits into from
May 2, 2025

Conversation

jnbooth
Copy link
Contributor

@jnbooth jnbooth commented Apr 1, 2025

Suppose a user creates a function like this:

fn do_something<T: Upcast<MyObject>>(object: &T);

It should be possible to call do_something(object) where object is &MyObject.

The Upcast<Self> implementations are all no-ops.

Copy link

codecov bot commented Apr 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (5d3b2de) to head (9bb1823).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1247   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           73        73           
  Lines        12634     12634           
=========================================
  Hits         12634     12634           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@LeonMatthesKDAB LeonMatthesKDAB left a comment

Choose a reason for hiding this comment

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

Thank you @jnbooth.
Together with the changes that @BenFordTytherington is working on in #1252 this means we'll have to use somewhat ugly/verbose disambiguation syntax to specify the type to upcast to, but that's just how it has to be I guess.

@LeonMatthesKDAB LeonMatthesKDAB enabled auto-merge (squash) May 2, 2025 16:49
@LeonMatthesKDAB LeonMatthesKDAB merged commit c7a92c5 into KDAB:main May 2, 2025
16 checks passed
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.

2 participants