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 default generic type to ArbitraryOrd #27

Merged
merged 1 commit into from
Dec 29, 2024

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Dec 29, 2024

The PartialOrd trait uses a default generic type for the right hand side of the comparison. This is useful for example to compare an object to a foreign type. For the same reasons we should provide a default generic type to ArbitraryOrd.

Add generic type to ArbitraryOrd and default to Self. This adds functionality without effecting current users in any way.

I believe this also makes the trait object safe C-OBJECT

Done while checking off item in #16

The `PartialOrd` trait uses a default generic type for the right hand
side of the comparison. This is useful for example to compare an object
to a foreign type. For the same reasons we should provide a default
generic type to `ArbitraryOrd`.

Add generic type to `ArbitraryOrd` and default to `Self`.

I believe this also makes the trait object safe.
@tcharding tcharding changed the title Add default generic type to ArbitraryOrd Add default generic type to ArbitraryOrd Dec 29, 2024
@tcharding
Copy link
Member Author

Hey @apoelstra would you take a look at this one please and check that my understanding is correct (re the object safety thing). No rush.

@tcharding tcharding merged commit 760bbff into rust-bitcoin:master Dec 29, 2024
11 checks passed
@tcharding tcharding deleted the 12-30-default-generic branch December 29, 2024 21:24
@apoelstra
Copy link
Member

Yeah, this looks to me like it'll make the trait object-safe (though it's not really obvious to me that you want/need object-safety for ArbitraryOrd. Ord isn't object-safe is it?)

As I mentioned elsewhere you can API-test whether a given trait is object-safe.

@tcharding
Copy link
Member Author

TIL Box<dyn Trait> to test for object safety - mad.

Please see #31

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