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

Implement Default for AssumeNotNull #3941

Merged
merged 1 commit into from
Feb 20, 2024
Merged

Conversation

dullbananas
Copy link
Contributor

No description provided.

@weiznich weiznich requested a review from a team February 20, 2024 07:45
@Ten0
Copy link
Member

Ten0 commented Feb 20, 2024

Just not sure to what extent this is backwards compatible - can't users implement that in their own crate if they own T?

@weiznich
Copy link
Member

That should be backward compatible. At least the following code does not compile in a downstream crate with an error message related to the fact that you cannot implement a foreign trait for a for foreign type.

struct Foo;

impl Default for diesel::dsl::AssumeNotNull<Foo> {
    fn default() -> Self {
        todo!()
    }
}

This only works if the trait itself has a type parameter or if the type is marked at fundamental. (Beside of that downstream users wouldn't be able to provide a meaningful implementation of Default for that type, as it exposes no public fields and no constructor.)

@weiznich weiznich added this pull request to the merge queue Feb 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Feb 20, 2024
@weiznich weiznich added this pull request to the merge queue Feb 20, 2024
Merged via the queue into diesel-rs:master with commit 6c171bf Feb 20, 2024
46 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.

3 participants