-
Notifications
You must be signed in to change notification settings - Fork 42
Conversation
- apply cargo fix --edition - probably can remove most `extern crate foo;`
src/application.rs
Outdated
use commands::KmsCommand; | ||
use config::KmsConfig; | ||
use crate::commands::KmsCommand; | ||
use crate::config::KmsConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on how much you care it might be nice to collapse these into nested imports (I've been doing that in my own crates), e.g.
use crate::{
commands::KmsCommand,
config::KmsConfig
};
- use dyn keyword - use crate:: (absolute path) - anonymous lifetimes - inclusive ranges via `..=` - remove some extern crate
error: methods called `new` usually return `Self`
src/unix_connection.rs
Outdated
@@ -12,6 +12,7 @@ impl<IoHandler> UnixConnection<IoHandler> | |||
where | |||
IoHandler: io::Read + io::Write + Send + Sync, | |||
{ | |||
#[allow(clippy::new_ret_no_self)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, lots of fun with these... I have mostly been adding an allow
for these as well, although sometimes there are better solutions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this could be a impl From<IoHandler> for UnixConnection<IoHandler>
instead of new
. On the other hand we do not err in any case and could also change the method below to:
#[allow(clippy::new_ret_no_self)] | |
/// Create a new `UnixConnection` for the given socket | |
pub fn new(socket: IoHandler) -> Self { | |
Self { socket } | |
} |
tendermint-rs/src/chain/id.rs
Outdated
@@ -21,6 +21,7 @@ pub const MAX_LENGTH: usize = 50; | |||
pub struct Id([u8; MAX_LENGTH]); | |||
|
|||
impl Id { | |||
#[allow(clippy::new_ret_no_self)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively this could be impl FromStr for Id
.
Edit: oh hey wait, that already exists! 😂 https://github.com/tendermint/kms/blob/4983f3b2426a783bd7d3c1ea9b4ea3dce1080f79/tendermint-rs/src/chain/id.rs#L80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could still remove pub fn new
and place the logic into from_str
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
); | ||
process::exit(1); | ||
}, | ||
Some(ref key_type) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe combine this with the if
below?
Some(ref key_type) if key_type != DEFAULT_KEY_TYPE => {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively the match could be replaced with:
if let Some(key_type) = self.key_type.as_ref() {
...in which case you'd still need the nested if
s, but you can get rid of the None
below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh GitHub refresh not keeping up with your changes. I'll call this close enough 😉
extern crate foo;
sdyn
keyworduse crate::
(absolute path)..=