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

chore!: PartialOrd -> Ord bound for hashcollections #203

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

dj8yfo
Copy link
Collaborator

@dj8yfo dj8yfo commented Aug 22, 2023

This pr is part of #51 resolution.

It addresses the following comments of review:

tmp
tmp

Second comment is addressed by second commit: feat!: raise bound on keys in hashcollections PartialOrd -> Ord.
Code with f32 and f64 won't be affected by this breaking change, as f32 and f64 aren't Eq, so it's not possible to construct HashSet or HashMap with these types as keys in the first place (insert in both collections require Eq bound).

@dj8yfo dj8yfo changed the title chore: de_strict_order to default; PartialOrd -> Ord bound for hashcollections chore!: de_strict_order to default; PartialOrd -> Ord bound for hashcollections Aug 22, 2023
@dj8yfo dj8yfo marked this pull request as ready for review August 22, 2023 16:19
@dj8yfo dj8yfo requested a review from frol as a code owner August 22, 2023 16:19
@frol
Copy link
Collaborator

frol commented Aug 24, 2023

It's a bit surprising that that's not the default. Probably makes sense to explain why we need this feature:

@matklad The reasoning for that de_strict_order was not enabled by default is that extra checks add performance hit (#162 (comment)), and if any of the dependencies use borsh with default features, there is no way to opt-out. Canonical deserialization does not seem like a crucial feature even for nearcore, so I would keep it off by default to trade correctness for performance.

@dj8yfo What do you think?

@matklad
Copy link
Contributor

matklad commented Aug 24, 2023

Sorry for being confusing, what I meant is:

this is surprising, so it must be documented clearly

not

this is surprising, so it must be changed

@dj8yfo
Copy link
Collaborator Author

dj8yfo commented Aug 24, 2023

Removed commit with making de_strict_order a default feature from history of this pr

@dj8yfo dj8yfo changed the title chore!: de_strict_order to default; PartialOrd -> Ord bound for hashcollections chore!: PartialOrd -> Ord bound for hashcollections Aug 25, 2023
Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

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

I cannot think of how we could handle non-Ord types in collections, so I believe it is a good move, but let's see how it turns out when we upgrade nearcore / near-sdk-rs.

@dj8yfo
Copy link
Collaborator Author

dj8yfo commented Aug 29, 2023

So far i've only noticed this example, affected by this PartialOrd -> Ord change, but in this case the types are either already Ord or Ord can be easily added to #[derive(...)]

@dj8yfo dj8yfo merged commit c1a72c4 into master Aug 29, 2023
7 checks passed
@dj8yfo dj8yfo deleted the de_strict_order_to_default branch August 29, 2023 12:46
@frol frol mentioned this pull request Aug 29, 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.

3 participants