4 ms·
A few quick things. Posting to users.rust-lang.org will probably get you more comments than here. Did you run clippy on this code? Rustfmt? those are two easy
by steveklabnik 8y ago
A few quick things. Posting to users.rust-lang.org will probably get you more comments than here.
Did you run clippy on this code? Rustfmt? those are two easy things.
#![allow(dead_code)] is pretty suspicious...
I would use format! here https://github.com/grzegorzk/logmap/blob/master/src/logmap.rs#L50-L59 https://github.com/grzegorzk/logmap/blob/master/src/logmap.r...
https://github.com/grzegorzk/logmap/blob/master/src/logmap.rs#L90-L93 https://github.com/grzegorzk/logmap/blob/master/src/logmap.r... could be unwrap_or_else
https://github.com/grzegorzk/logmap/blob/master/src/logmap.rs#L101 https://github.com/grzegorzk/logmap/blob/master/src/logmap.r... should just be `log_filters`, no need for the return;
naming functions with `_` like https://github.com/grzegorzk/logmap/blob/master/src/logmap.rs#L104 https://github.com/grzegorzk/logmap/blob/master/src/logmap.r... is not idiomatic. It's already not public, no need for `_`.
lines like https://github.com/grzegorzk/logmap/blob/master/src/logmap.rs#L117-L118 https://github.com/grzegorzk/logmap/blob/master/src/logmap.r... should be one line, no need for the type ascription there.
the package is already called logmap, so https://github.com/grzegorzk/logmap/blob/master/src/lib.rs https://github.com/grzegorzk/logmap/blob/master/src/lib.rs is just redundant and adds an extra layer, that is, `logmap::logmap::foo` rather than just `logmap::foo`.
This isn't an idiom issue, but you might like structopt over getopts.
- gkuk 8y agoOh why why... was I not aware of cargo-clippy before...
- gkuk 8y agoMany thanks for your great feedback Steve! I had some issues with running unit tests and at the time I figured if I add lib.rs I can make my unit tests to run. I did not like logmap::logmap::foo and definitely need to revisit that.