diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-06-13 00:58:32 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-06-13 00:58:32 +0200 |
| commit | 9352a0f7cfdd5f5fc102a25d8a93218bc3dbe462 (patch) | |
| tree | b998430c307c10defb79d91abe5d30471c5c4f12 /crates/turtle/src/atuin_common | |
| parent | chore(treewide): Remove `cargo` warnings to 0 (diff) | |
| download | atuin-9352a0f7cfdd5f5fc102a25d8a93218bc3dbe462.zip | |
chore(treewide): Fix some of `clippy`'s error
Just a run of `cargo clippy --fix`
Diffstat (limited to 'crates/turtle/src/atuin_common')
| -rw-r--r-- | crates/turtle/src/atuin_common/record.rs | 8 | ||||
| -rw-r--r-- | crates/turtle/src/atuin_common/shell.rs | 40 | ||||
| -rw-r--r-- | crates/turtle/src/atuin_common/utils.rs | 8 |
3 files changed, 28 insertions, 28 deletions
diff --git a/crates/turtle/src/atuin_common/record.rs b/crates/turtle/src/atuin_common/record.rs index 7b2a1a10..f8f9f8a7 100644 --- a/crates/turtle/src/atuin_common/record.rs +++ b/crates/turtle/src/atuin_common/record.rs @@ -106,8 +106,8 @@ impl Extend<(HostId, String, RecordIdx)> for RecordStatus { } impl RecordStatus { - pub(crate) fn new() -> RecordStatus { - RecordStatus { + pub(crate) fn new() -> Self { + Self { hosts: HashMap::new(), } } @@ -246,7 +246,7 @@ impl Record<EncryptedData> { self, old_key: &[u8; 32], new_key: &[u8; 32], - ) -> Result<Record<EncryptedData>> { + ) -> Result<Self> { let ad = AdditionalData { id: &self.id, version: &self.version, @@ -254,7 +254,7 @@ impl Record<EncryptedData> { host: &self.host.id, idx: &self.idx, }; - Ok(Record { + Ok(Self { data: E::re_encrypt(self.data, ad, old_key, new_key)?, id: self.id, host: self.host, diff --git a/crates/turtle/src/atuin_common/shell.rs b/crates/turtle/src/atuin_common/shell.rs index d259b99e..880ff00f 100644 --- a/crates/turtle/src/atuin_common/shell.rs +++ b/crates/turtle/src/atuin_common/shell.rs @@ -14,15 +14,15 @@ pub(crate) enum Shell { impl std::fmt::Display for Shell { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let shell = match self { - Shell::Bash => "bash", - Shell::Fish => "fish", - Shell::Zsh => "zsh", - Shell::Nu => "nu", - Shell::Xonsh => "xonsh", - Shell::Sh => "sh", - Shell::Powershell => "powershell", + Self::Bash => "bash", + Self::Fish => "fish", + Self::Zsh => "zsh", + Self::Nu => "nu", + Self::Xonsh => "xonsh", + Self::Sh => "sh", + Self::Powershell => "powershell", - Shell::Unknown => "unknown", + Self::Unknown => "unknown", }; write!(f, "{shell}") @@ -30,23 +30,23 @@ impl std::fmt::Display for Shell { } impl Shell { - pub(crate) fn from_env() -> Shell { - std::env::var("ATUIN_SHELL").map_or(Shell::Unknown, |shell| { - Shell::from_string(shell.trim().to_lowercase().as_str()) + pub(crate) fn from_env() -> Self { + std::env::var("ATUIN_SHELL").map_or(Self::Unknown, |shell| { + Self::from_string(shell.trim().to_lowercase().as_str()) }) } - pub(crate) fn from_string(name: &str) -> Shell { + pub(crate) fn from_string(name: &str) -> Self { match name { - "bash" => Shell::Bash, - "fish" => Shell::Fish, - "zsh" => Shell::Zsh, - "xonsh" => Shell::Xonsh, - "nu" => Shell::Nu, - "sh" => Shell::Sh, - "powershell" => Shell::Powershell, + "bash" => Self::Bash, + "fish" => Self::Fish, + "zsh" => Self::Zsh, + "xonsh" => Self::Xonsh, + "nu" => Self::Nu, + "sh" => Self::Sh, + "powershell" => Self::Powershell, - _ => Shell::Unknown, + _ => Self::Unknown, } } } diff --git a/crates/turtle/src/atuin_common/utils.rs b/crates/turtle/src/atuin_common/utils.rs index c8c2776e..aa662979 100644 --- a/crates/turtle/src/atuin_common/utils.rs +++ b/crates/turtle/src/atuin_common/utils.rs @@ -106,7 +106,7 @@ pub(crate) fn get_current_dir() -> String { Ok(v) => v, Err(_) => match env::current_dir() { Ok(dir) => dir.display().to_string(), - Err(_) => String::from(""), + Err(_) => String::new(), }, } } @@ -124,9 +124,7 @@ pub(crate) fn broken_symlink<P: Into<PathBuf>>(path: P) -> bool { /// reflect the actual command run rather than just the printable characters. pub(crate) trait Escapable: AsRef<str> { fn escape_control(&self) -> Cow<'_, str> { - if !self.as_ref().contains(|c: char| c.is_ascii_control()) { - self.as_ref().into() - } else { + if self.as_ref().contains(|c: char| c.is_ascii_control()) { let mut remaining = self.as_ref(); // Not a perfect way to reserve space but should reduce the allocations let mut buf = String::with_capacity(remaining.len()); @@ -142,6 +140,8 @@ pub(crate) trait Escapable: AsRef<str> { } buf.push_str(remaining); buf.into() + } else { + self.as_ref().into() } } } |
