Skip to content

Commit 5dfe219

Browse files
committed
Appease clippy be removing unnecessary borrows.
1 parent 77554d7 commit 5dfe219

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

build.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,25 @@ fn set_args(mut p: Manual, y: &Yaml) -> Manual {
4343
let takes_value = arg.get(&string_to_yaml("takes_value"));
4444
if takes_value.is_none() || !takes_value.unwrap().as_bool().unwrap() {
4545
let mut f = Flag::new()
46-
.long(format!("--{}", parse_str(&arg, "long")).as_str())
47-
.help(parse_str(&arg, "help").as_str());
48-
let short = parse_str(&arg, "short");
46+
.long(format!("--{}", parse_str(arg, "long")).as_str())
47+
.help(parse_str(arg, "help").as_str());
48+
let short = parse_str(arg, "short");
4949
if !short.is_empty() {
5050
f = f.short(format!("-{}", short).as_str());
5151
}
5252
p = p.flag(f);
5353
} else {
54-
let o_val = parse_str(&arg, "value_name");
54+
let o_val = parse_str(arg, "value_name");
5555
let key = if !o_val.is_empty() {
5656
o_val.as_str()
5757
} else {
5858
key
5959
};
6060
let mut o = Opt::new(key)
61-
.long(format!("--{}", parse_str(&arg, "long")).as_str())
62-
.help(parse_str(&arg, "help").as_str());
63-
let short = parse_str(&arg, "short");
64-
let default_value = parse_str(&arg, "default_value");
61+
.long(format!("--{}", parse_str(arg, "long")).as_str())
62+
.help(parse_str(arg, "help").as_str());
63+
let short = parse_str(arg, "short");
64+
let default_value = parse_str(arg, "default_value");
6565
if !short.is_empty() {
6666
o = o.short(format!("-{}", short).as_str());
6767
}

src/git.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn set_project_config(field_name: &str, value: &str) {
9191
/// Get a value for the given global git-req config
9292
pub fn get_req_config(domain: &str, field: &str) -> Option<String> {
9393
let slug = slugify_domain(domain);
94-
let cfg = Config::open(&Path::new(
94+
let cfg = Config::open(Path::new(
9595
&shellexpand::tilde("~/.gitreqconfig").to_string(),
9696
))
9797
.unwrap();
@@ -101,7 +101,7 @@ pub fn get_req_config(domain: &str, field: &str) -> Option<String> {
101101
/// Set a value for the global git-req configuration
102102
pub fn set_req_config(domain: &str, field: &str, value: &str) {
103103
let slug = slugify_domain(domain);
104-
let mut cfg = Config::open(&Path::new(
104+
let mut cfg = Config::open(Path::new(
105105
&shellexpand::tilde("~/.gitreqconfig").to_string(),
106106
))
107107
.unwrap();
@@ -112,7 +112,7 @@ pub fn set_req_config(domain: &str, field: &str, value: &str) {
112112
/// Clear the value for the lobal git-req configuration
113113
pub fn delete_req_config(domain: &str, field: &str) -> Result<(), git2::Error> {
114114
let slug = slugify_domain(domain);
115-
let mut cfg = Config::open(&Path::new(
115+
let mut cfg = Config::open(Path::new(
116116
&shellexpand::tilde("~/.gitreqconfig").to_string(),
117117
))
118118
.unwrap();
@@ -215,12 +215,12 @@ pub fn checkout_branch(
215215
}
216216
Err(_) => {
217217
// Fetch the remote branch if there's no local branch with the correct name
218-
let mut fetch_args = vec!["fetch", &remote_name];
218+
let mut fetch_args = vec!["fetch", remote_name];
219219
let remote_to_local_binding = format!("{}:{}", remote_branch_name, local_branch_name);
220220
fetch_args.push(if is_virtual_remote_branch {
221221
&remote_to_local_binding
222222
} else {
223-
&remote_branch_name
223+
remote_branch_name
224224
});
225225
if cmd("git", fetch_args).run().is_err() {
226226
return Err(anyhow!(

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn checkout_mr(remote_name: &str, mr_id: i64) {
8484
fn clear_domain_key(remote_name: &str) {
8585
trace!("Deleting domain key");
8686
let mut remote = get_remote_hard(remote_name, false);
87-
let deleted = match git::delete_req_config(&remote.get_domain(), "apikey") {
87+
let deleted = match git::delete_req_config(remote.get_domain(), "apikey") {
8888
Ok(_) => Ok(true),
8989
Err(e) => match e.code() {
9090
ErrorCode::NotFound => Ok(false),
@@ -108,7 +108,7 @@ fn clear_domain_key(remote_name: &str) {
108108
fn set_domain_key(remote_name: &str, new_key: &str) {
109109
trace!("Setting domain key: {}", new_key);
110110
let mut remote = get_remote_hard(remote_name, false);
111-
git::set_req_config(&remote.get_domain(), "apikey", new_key);
111+
git::set_req_config(remote.get_domain(), "apikey", new_key);
112112
eprintln!("{}", "Domain key changed!".green());
113113
}
114114

@@ -233,7 +233,7 @@ fn main() {
233233
set_default_remote(remote_name);
234234
} else if let Some(shell_name) = matches.value_of("GENERATE_COMPLETIONS") {
235235
app = build_cli();
236-
generate_completion(&mut app, &shell_name);
236+
generate_completion(&mut app, shell_name);
237237
} else {
238238
let request_id = matches.value_of("REQUEST_ID").unwrap();
239239
let mr_id = if request_id == "-" {

src/remotes/gitlab.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Remote for GitLab {
8383

8484
/// Query the GitLab API
8585
fn query_gitlab_api(url: &str, token: &str) -> Result<ureq::Response, ureq::Response> {
86-
let response = ureq::get(url).set("PRIVATE-TOKEN", &token).call();
86+
let response = ureq::get(url).set("PRIVATE-TOKEN", token).call();
8787
if response.error() {
8888
return Err(response);
8989
}

src/remotes/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn get_domain(origin: &str) -> Result<&str> {
6767

6868
/// Get the API key for the given domain. If absent, prompt.
6969
fn get_api_key(domain: &str) -> String {
70-
git::get_req_config(&domain, "apikey").unwrap_or_else(|| {
70+
git::get_req_config(domain, "apikey").unwrap_or_else(|| {
7171
let mut newkey = String::new();
7272
println!("No API token for {} found. See https://github.com/arusahni/git-req/wiki/API-Keys for instructions.", domain);
7373
print!("{} API token: ", domain);
@@ -76,7 +76,7 @@ fn get_api_key(domain: &str) -> String {
7676
.read_line(&mut newkey)
7777
.expect("Did not input a correct key");
7878
trace!("New Key: {}", &newkey);
79-
git::set_req_config(&domain, "apikey", &newkey.trim());
79+
git::set_req_config(domain, "apikey", newkey.trim());
8080
newkey.trim().to_string()
8181
})
8282
}
@@ -127,7 +127,7 @@ pub fn get_remote(remote_name: &str, origin: &str, skip_api_key: bool) -> Result
127127
api_key: String::from(""),
128128
};
129129
if !skip_api_key {
130-
let apikey = get_api_key(&domain);
130+
let apikey = get_api_key(domain);
131131
info!("API Key: {}", &apikey);
132132
remote.api_key = apikey;
133133
}

0 commit comments

Comments
 (0)