Skip to content

added trait to constrain types#2

Open
dustins wants to merge 1 commit intolgrahl:masterfrom
dustins:master
Open

added trait to constrain types#2
dustins wants to merge 1 commit intolgrahl:masterfrom
dustins:master

Conversation

@dustins
Copy link
Copy Markdown

@dustins dustins commented Jun 9, 2021

No description provided.

@dustins dustins changed the title added trait constrain types added trait to constrain types Jun 10, 2021
@lgrahl
Copy link
Copy Markdown
Owner

lgrahl commented Jun 15, 2021

Thanks. I'm wondering: Do you use the lib for a project? I mostly wrote it to get familiar with Rust macros. 🙂

@dustins
Copy link
Copy Markdown
Author

dustins commented Jun 15, 2021

Funny you say that because looking at your code helped me start to understand how Rust macros worked!

I ended up not using the library because I needed it to work slightly differently and so rewrote it as needed. You excellently implemented it to spec but in the scenario where a comparison is undefined and the behavior is left up to specific implementations I wanted to define that behavior so I could implement Ord instead of just PartialOrd. While I was looking at how you did everything I saw your comment about constraining the types so I wanted to contribute back as a thanks since it was nice you had created a crate for this already! 😀

For my use I'm using it to number packets so they can be reorganized by the receiver so I am only ever comparing them to relatively nearby numbers. But I had to have Ord implemented to do that.

From RFC1982:

Thus the problem case is left undefined, implementations are free to return either result, or to flag an error, and users must take care not to depend on any particular outcome. Usually this will mean avoiding allowing those particular pairs of numbers to co-exist.

Making the undefined comparison behavior be configurable one way or another could potentially be added probably through Wrapper Types when comparing. But I wasn't sure how you'd feel about adding those into the project and I didn't want to waste time writing changes to the library you might not be interested in.

@dustins
Copy link
Copy Markdown
Author

dustins commented May 21, 2024

I'm cleaning up my PRs and saw this is still open. Any plans to merge this in or should I close this PR?

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