Skip to content

Add new pattern: use custom traits to avoid complex type bounds #437

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

neithernut
Copy link
Contributor

Introducing traits as an abstraction should be obvious enough in many Rust projects. However, I often found myself introduce "random" type bounds involving Fn that would grow unwieldy first until I finally introduced a new trait. So maybe this is advise some people, especially new Rust users, will find useful.

I did not include a Motivation section because I felt it was redundant. I also did not (yet) write a Discussion section. There are probably some similar uses of type classes in functional programming languages that we could refer to.

Introducing traits as an abstraction should be obvious enough in many
Rust projects. However, I often found myself introduce "random" type
bounds involving `Fn` that would grow unwieldy first until I finally
introduced a new trait. So maybe this is advise some people, especially
new Rust users, will find useful.
@neithernut
Copy link
Contributor Author

The style check currently fails, but I feel it's suggestions are wrong: they would result in a line longer than 80 characters, and they clearly don't handle footnotes correctly. Any suggestions for resolving this?

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