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

Replace CopyOnto by Push #28

Merged
merged 5 commits into from
May 24, 2024
Merged

Replace CopyOnto by Push #28

merged 5 commits into from
May 24, 2024

Conversation

antiguru
Copy link
Owner

@antiguru antiguru commented May 22, 2024

Replace the CopyOnto trait by a Push trait, plus other housekeeping changes. The motivation for this is are Rust's orphan rules when implementing traits: A downstream crate can implement Trait<T> for LocalType, but not Trait<LocalType> for T when Trait is defined in an upstream crate. For this reason, we switch the types for CopyOnto implementations and give it a better name.

Similarly, this updates the ReserveItems trait suffering from the same issue.

Additionally, clean up some cruft and add implementations I overlooked.

antiguru added 2 commits May 21, 2024 21:56
Swap the parameters for CopyOnto. Previously, we'd implement CopyOnto
for a specific type, specifying the region as a parameter to CopyOnto. This
has the undesired side-effect that downstream crates cannot implement the
trait for their own regions due to Rust's orphan rules. Switching the
parameters around (Push<T> for Region) moves a local type into the T0
position, which is compatible with the orphan rules.

Similarly updates ReserveItems.

Signed-off-by: Moritz Hoffmann <[email protected]>
antiguru added 2 commits May 24, 2024 10:24
Signed-off-by: Moritz Hoffmann <[email protected]>
Signed-off-by: Moritz Hoffmann <[email protected]>
@antiguru antiguru changed the title Adding several implementations that were missing. Replace CopyOnto by Push May 24, 2024
Signed-off-by: Moritz Hoffmann <[email protected]>
@antiguru antiguru merged commit 4fe52b5 into main May 24, 2024
8 checks passed
@antiguru antiguru deleted the missing_impls branch May 24, 2024 18:02
@github-actions github-actions bot mentioned this pull request May 24, 2024
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.

1 participant