aboutsummaryrefslogtreecommitdiffstats
path: root/src/prompt.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-03-26 00:14:38 -0400
committerJesse Luehrs <doy@tozt.net>2023-03-26 00:14:38 -0400
commit6f19f96053db7475e2376c9dd3179c4dd2264df8 (patch)
treea6c3d3f02f7026b7e98a3e007ff6a37e2a77fd97 /src/prompt.rs
parent93e6a9a08aec3cbb8b847a815ad905aa0d0bffca (diff)
downloadfancy-prompt-6f19f96053db7475e2376c9dd3179c4dd2264df8.tar.gz
fancy-prompt-6f19f96053db7475e2376c9dd3179c4dd2264df8.zip
clippy
Diffstat (limited to 'src/prompt.rs')
-rw-r--r--src/prompt.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/prompt.rs b/src/prompt.rs
index a68b01e..1ab60d2 100644
--- a/src/prompt.rs
+++ b/src/prompt.rs
@@ -1,7 +1,3 @@
-use regex;
-use std;
-use term;
-
use std::fmt::Write;
use crate::colors;
@@ -219,11 +215,11 @@ impl Prompt {
}
fn format_vcs(&self) -> Option<String> {
- format_vcs(self.data.vcs_info.as_ref().map(|v| &**v))
+ format_vcs(self.data.vcs_info.as_deref())
}
fn vcs_color(&self) -> String {
- vcs_color(self.data.vcs_info.as_ref().map(|v| &**v))
+ vcs_color(self.data.vcs_info.as_deref())
}
fn print_host<W: std::io::Write>(
@@ -254,9 +250,7 @@ impl Prompt {
fn battery_discharge_color(usage: f64, charging: bool) -> &'static str {
if usage >= 0.8 {
"battery_full"
- } else if charging {
- "default"
- } else if usage >= 0.4 {
+ } else if charging || usage >= 0.4 {
"default"
} else if usage >= 0.15 {
"battery_warn"
@@ -309,7 +303,7 @@ fn format_vcs(vcs_info: Option<&dyn vcs::VcsInfo>) -> Option<String> {
}
})
.unwrap_or_else(|| String::from("???"));
- if branch != "" {
+ if !branch.is_empty() {
write!(vcs, ":").unwrap();
}
write!(vcs, "{}", branch).unwrap();
@@ -417,7 +411,7 @@ fn compress_vcs(vcs: &str, len: usize) -> String {
let branch_len = len - prefix_len - suffix_len;
let branch_re = regex::Regex::new(&format!(
r"(:[^:]{{{}}})[^:]*([^:]{{3}}:?)",
- (branch_len - 6).to_string()
+ (branch_len - 6)
))
.unwrap();
branch_re.replace(vcs, "$1...$2").into_owned()