From f252f4c6595421339cb3119f1ca8ef491077f365 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 26 Mar 2023 00:08:59 -0400 Subject: bump to 2021 edition --- Cargo.toml | 1 + src/args.rs | 2 +- src/colors.rs | 20 ++++++++++---------- src/data.rs | 18 ++++++------------ src/prompt.rs | 30 +++++++++++++++--------------- src/vcs/git.rs | 2 +- src/vcs/mod.rs | 2 +- 7 files changed, 35 insertions(+), 40 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8e7a25c..d0b36d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ license = "MIT" version = "0.1.6" authors = ["Jesse Luehrs "] exclude = ["screenshots/*"] +edition = "2021" [badges] travis-ci = { repository = "doy/fancy-prompt", branch = "master" } diff --git a/src/args.rs b/src/args.rs index 90e33b7..bae31f2 100644 --- a/src/args.rs +++ b/src/args.rs @@ -1,6 +1,6 @@ use clap; -use colors; +use crate::colors; pub struct CommandLineOptions { pub shell: colors::ShellType, diff --git a/src/colors.rs b/src/colors.rs index bb1744c..0e53fdc 100644 --- a/src/colors.rs +++ b/src/colors.rs @@ -97,7 +97,7 @@ impl Colors { pub fn print( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, color: &str, text: &str, ) { @@ -107,7 +107,7 @@ impl Colors { pub fn pad( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, len: usize, ) { write!(t, "{}", " ".repeat(len)).unwrap(); @@ -115,14 +115,14 @@ impl Colors { pub fn newline( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, ) { write!(t, "{}", "\n").unwrap(); } pub fn print_host( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, host: Option<&str>, text: &str, ) { @@ -134,7 +134,7 @@ impl Colors { pub fn print_user( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, user: Option<&str>, text: &str, ) { @@ -146,7 +146,7 @@ impl Colors { fn print_with_color( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, color: Option<&term::color::Color>, text: &str, ) { @@ -157,7 +157,7 @@ impl Colors { fn print_reset( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, ) { self.print_wrapped(t, |t| { t.reset().unwrap(); @@ -166,7 +166,7 @@ impl Colors { fn print_color( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, color: Option<&term::color::Color>, ) { self.print_wrapped(t, |t| { @@ -190,11 +190,11 @@ impl Colors { fn print_wrapped( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, printer: T, ) where - T: FnOnce(&mut term::Terminal), + T: FnOnce(&mut dyn term::Terminal), { match self.shell_type { ShellType::Bash => { diff --git a/src/data.rs b/src/data.rs index e1a77a0..322f373 100644 --- a/src/data.rs +++ b/src/data.rs @@ -1,13 +1,7 @@ -use chrono; -use hostname; -use term_size; -use std; -use users; - -use args; -use colors; -use power; -use vcs; +use crate::args; +use crate::colors; +use crate::power; +use crate::vcs; pub struct PromptData { pub shell: colors::ShellType, @@ -20,7 +14,7 @@ pub struct PromptData { pub is_root: bool, pub time: chrono::DateTime, pub power_info: power::PowerInfo, - pub vcs_info: Option>, + pub vcs_info: Option>, } pub fn collect(opts: args::CommandLineOptions) -> PromptData { @@ -107,6 +101,6 @@ fn power_info() -> power::PowerInfo { power::PowerInfo::new() } -fn vcs_info() -> Option> { +fn vcs_info() -> Option> { vcs::detect() } diff --git a/src/prompt.rs b/src/prompt.rs index 4b207db..39411f0 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -4,10 +4,10 @@ use term; use std::fmt::Write; -use colors; -use data; -use sys; -use vcs; +use crate::colors; +use crate::data; +use crate::sys; +use crate::vcs; pub struct Prompt { colors: colors::Colors, @@ -113,7 +113,7 @@ impl Prompt { fn display_path( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, path: &str, path_color: &str, vcs: Option<&str>, @@ -130,7 +130,7 @@ impl Prompt { fn display_border( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, len: usize ) { self.colors.print(t, "default", &"-".repeat(len)); @@ -138,7 +138,7 @@ impl Prompt { fn display_battery( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, len: usize ) { self.print_host(t, "{"); @@ -171,7 +171,7 @@ impl Prompt { fn display_identity( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, user: &str, host: &str, ) { @@ -182,7 +182,7 @@ impl Prompt { fn display_time( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, ) { self.print_host(t, "["); self.colors.print( @@ -195,7 +195,7 @@ impl Prompt { fn display_error_code( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, ) { let error_code_color = if self.data.error_code == 0 { "default" @@ -212,7 +212,7 @@ impl Prompt { fn display_prompt( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, ) { let prompt = if self.data.is_root { "#" @@ -233,7 +233,7 @@ impl Prompt { fn print_host( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, text: &str ) { self.colors.print_host(t, self.hostname(), text); @@ -241,7 +241,7 @@ impl Prompt { fn print_user( &self, - t: &mut term::Terminal, + t: &mut dyn term::Terminal, text: &str ) { self.colors.print_user(t, self.user(), text); @@ -292,7 +292,7 @@ fn path_color(path: Option<&std::path::Path>) -> String { .unwrap_or_else(|| String::from("path_not_exist")) } -fn format_vcs(vcs_info: Option<&vcs::VcsInfo>) -> Option { +fn format_vcs(vcs_info: Option<&dyn vcs::VcsInfo>) -> Option { vcs_info.as_ref().map(|vcs_info| { let mut vcs = String::new(); @@ -354,7 +354,7 @@ fn format_vcs(vcs_info: Option<&vcs::VcsInfo>) -> Option { }) } -fn vcs_color(vcs_info: Option<&vcs::VcsInfo>) -> String { +fn vcs_color(vcs_info: Option<&dyn vcs::VcsInfo>) -> String { vcs_info .as_ref() .map(|vcs_info| { diff --git a/src/vcs/git.rs b/src/vcs/git.rs index c745c46..5b8ad96 100644 --- a/src/vcs/git.rs +++ b/src/vcs/git.rs @@ -185,7 +185,7 @@ impl super::VcsInfo for GitInfo { } } -pub fn detect() -> Option> { +pub fn detect() -> Option> { start_talking_about_time!("git::detect"); let git = git2::Repository::open_from_env().ok(); diff --git a/src/vcs/mod.rs b/src/vcs/mod.rs index b7a9fc7..e672ec6 100644 --- a/src/vcs/mod.rs +++ b/src/vcs/mod.rs @@ -38,7 +38,7 @@ pub trait VcsInfo { } } -pub fn detect() -> Option> { +pub fn detect() -> Option> { if let Some(git) = git::detect() { Some(git) } -- cgit v1.2.3-54-g00ecf