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

Please derive/implement Default trait #18

Closed
imp opened this issue Mar 11, 2020 · 9 comments
Closed

Please derive/implement Default trait #18

imp opened this issue Mar 11, 2020 · 9 comments

Comments

@imp
Copy link
Contributor

imp commented Mar 11, 2020

The types in this crate are very useful and practical. The life of the consumers may be even easier if these types will be implementing Default trait. We are using these types as a part of a complex structures where Default is required. Right now it forces us to implement it manually instead of deriving.

@krisprice
Copy link
Owner

Hi @imp, is Default implemented for all the underlying traits already? If not what are you thinking the default should be, presumably 0/0 and ::/0?

@imp
Copy link
Contributor Author

imp commented Mar 12, 2020

Yes, I believe zeroes should be fine. Anything else would be very much opinionated. Those who care will set it to whatever they need, those who don't care - well, just don't care.

And that's for structs, right? Not traits?

@imp
Copy link
Contributor Author

imp commented Mar 12, 2020

Something like this - #19

@krisprice
Copy link
Owner

Thanks, my next question was going to be do you want to send me a pull request for it :-) Just for completeness, are you able to add some simple tests for your default implementation. Then I'll go ahead and merge it.

@imp
Copy link
Contributor Author

imp commented Mar 14, 2020

Added tests.

@imp
Copy link
Contributor Author

imp commented Mar 14, 2020

BTW, some files are with DOS EOL (CRLF), while others are UNIX (LF). This confuses editors and causes gratuitous reformatting.

> file src/*
src/ipext.rs:       ASCII text, with CRLF line terminators
src/ipnet.rs:       ASCII text, with CRLF line terminators
src/ipnet_serde.rs: c program text, ASCII text
src/lib.rs:         c program text, ASCII text
src/parser.rs:      ASCII text, with CRLF line terminators

Would you accept a PR to reformat all the files to LF line ending?

@krisprice
Copy link
Owner

Absolutely, your PRs are very much welcomed.

@imp
Copy link
Contributor Author

imp commented Mar 15, 2020

Thanks! #19 has been updated.

@krisprice
Copy link
Owner

Merged into 2.3.0.

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

No branches or pull requests

2 participants