Skip to content

Commit d06c3b0

Browse files
committed
chore(main): use &Path instead of &PathBuf
1 parent 3d0b467 commit d06c3b0

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn get_program_info() -> ProgramInfo {
3838
Err(_) => panic!("Can't get current working directory"),
3939
};
4040

41-
if args.len() == 0 {
41+
if args.is_empty() {
4242
// TODO should probably show help here
4343
println!("Please enter a valid command");
4444
exit(1);

src/commands/projects.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl AddProject {
1717

1818
// TODO This is needed because if the command was passed with empty arguments then it will
1919
// somehow escape the None arm above
20-
if args.len() == 0 {
20+
if args.is_empty() {
2121
println!("You must specify at least the name of the project");
2222
exit(1);
2323
}
@@ -55,7 +55,7 @@ impl SyncProjectBranch {
5555
Some(args) => args,
5656
};
5757

58-
if args.len() == 0 {
58+
if args.is_empty() {
5959
println!("You must specify project name and branch");
6060
exit(1);
6161
}

src/config.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::git::git_current_branch;
33
use serde::{Deserialize, Serialize};
44
use std::fs;
55
use std::io::prelude::*;
6+
use std::path::Path;
67
use std::path::PathBuf;
78

89
const CONFIG_INIT: &str = r#"
@@ -19,7 +20,7 @@ pub struct Project {
1920
}
2021

2122
impl Project {
22-
pub fn create(name: &str, path: &PathBuf) -> Project {
23+
pub fn create(name: &str, path: &Path) -> Project {
2324
Project {
2425
name: name.to_string(),
2526
path: path.to_path_buf(),
@@ -136,7 +137,7 @@ fn read_config_file(path: PathBuf) -> Config {
136137
}
137138
}
138139

139-
fn handle_config_file(path: &PathBuf) {
140+
fn handle_config_file(path: &Path) {
140141
// Get parent directory path
141142
let parent_dir = match path.parent() {
142143
None => panic!("Error getting parent directory from path"),
@@ -156,11 +157,11 @@ fn handle_config_file(path: &PathBuf) {
156157
}
157158
}
158159

159-
fn path_exists(path: &PathBuf) -> bool {
160+
fn path_exists(path: &Path) -> bool {
160161
fs::metadata(path).is_ok()
161162
}
162163

163-
fn create_config_file(path: &PathBuf) {
164+
fn create_config_file(path: &Path) {
164165
// Create the actual config file
165166
let mut file = match fs::File::create(path) {
166167
Err(err) => panic!(

src/git.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use std::fs;
22
use std::path::PathBuf;
3+
use std::path::Path;
34
use std::process::Command;
45

5-
pub fn get_repositories(path: &PathBuf) -> Vec<PathBuf> {
6+
pub fn get_repositories(path: &Path) -> Vec<PathBuf> {
67
let mut repositories: Vec<PathBuf> = Vec::new();
78

89
// TODO Must make sure that projects paths are directory the moment user enters them

0 commit comments

Comments
 (0)