summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-04-07 23:28:38 -0400
committerMatan Kushner <hello@matchai.me>2019-04-07 23:28:38 -0400
commit5086ba2f50526dc00d011b487cd1b39c817035cb (patch)
treef4317e9a71a937c99ce4f757f6c20a952a41daf3 /src
parent168a6fd7b145b8feb215220943428c9856f5d725 (diff)
A bit of tidying up
Diffstat (limited to 'src')
-rw-r--r--src/modules/character.rs9
-rw-r--r--src/modules/directory.rs11
-rw-r--r--src/print.rs2
3 files changed, 11 insertions, 11 deletions
diff --git a/src/modules/character.rs b/src/modules/character.rs
index 75d15ddc6..7bdbe6387 100644
--- a/src/modules/character.rs
+++ b/src/modules/character.rs
@@ -15,12 +15,11 @@ pub fn segment(args: &ArgMatches) -> Segment {
const COLOR_SUCCESS: Color = Color::Green;
const COLOR_FAILURE: Color = Color::Red;
- let color;
- if args.value_of("status_code").unwrap() == "0" {
- color = COLOR_SUCCESS;
+ let color = if args.value_of("status_code").unwrap() == "0" {
+ COLOR_SUCCESS
} else {
- color = COLOR_FAILURE;
- }
+ COLOR_FAILURE
+ };
Segment {
value: String::from(PROMPT_CHAR),
diff --git a/src/modules/directory.rs b/src/modules/directory.rs
index d78be9b1b..0725a7ea3 100644
--- a/src/modules/directory.rs
+++ b/src/modules/directory.rs
@@ -36,7 +36,7 @@ pub fn segment(_: &ArgMatches) -> Segment {
}
Segment {
- value: String::from(dir_string),
+ value: dir_string,
style: Style::from(COLOR_DIR).bold(),
..Default::default()
}
@@ -44,11 +44,12 @@ pub fn segment(_: &ArgMatches) -> Segment {
/// Get the root directory of a git repo
fn get_repo_root(repo: Repository) -> PathBuf {
- match repo.is_bare() {
- // A bare repo will return its root path
- true => repo.path().to_path_buf(),
+ if repo.is_bare() {
+ // Bare repos will return the repo root
+ repo.path().to_path_buf()
+ } else {
// Non-bare repos will return the path of `.git`
- false => repo.path().parent().unwrap().to_path_buf(),
+ repo.path().parent().unwrap().to_path_buf()
}
}
diff --git a/src/print.rs b/src/print.rs
index 2aad9019b..baf3ebe01 100644
--- a/src/print.rs
+++ b/src/print.rs
@@ -8,7 +8,7 @@ pub fn prompt(args: ArgMatches) {
default_prompt
.into_iter()
.map(|module| modules::handle(module, &args))
- .map(|segment| stringify_segment(segment))
+ .map(stringify_segment)
.for_each(|segment_string| print!("{}", segment_string));
}