From aaf0e4cfbfaa5a6a4cf99c9d58f4428fe70cf2dc Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Thu, 2 Sep 2021 19:19:09 +0200 Subject: [PATCH] &str instead of weird &String --- src/components/commit.rs | 2 +- src/components/create_branch.rs | 3 +-- src/components/cred.rs | 4 ++-- src/components/rename_branch.rs | 7 ++----- src/components/stashmsg.rs | 2 +- src/components/textinput.rs | 4 ++-- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/components/commit.rs b/src/components/commit.rs index 61a30abf..851bbb1f 100644 --- a/src/components/commit.rs +++ b/src/components/commit.rs @@ -179,7 +179,7 @@ impl CommitComponent { anyhow::bail!("config commit.gpgsign=true detected.\ngpg signing not supported.\ndeactivate in your repo/gitconfig to be able to commit without signing."); } - let msg = self.input.get_text().clone(); + let msg = self.input.get_text().to_string(); self.input.clear(); self.commit_with_msg(msg) } diff --git a/src/components/create_branch.rs b/src/components/create_branch.rs index c6bb2e88..37faa8c0 100644 --- a/src/components/create_branch.rs +++ b/src/components/create_branch.rs @@ -122,8 +122,7 @@ impl CreateBranchComponent { /// pub fn create_branch(&mut self) { - let res = - sync::create_branch(CWD, self.input.get_text().as_str()); + let res = sync::create_branch(CWD, self.input.get_text()); self.input.clear(); self.hide(); diff --git a/src/components/cred.rs b/src/components/cred.rs index 66725509..86766eb3 100644 --- a/src/components/cred.rs +++ b/src/components/cred.rs @@ -119,7 +119,7 @@ impl Component for CredComponent { Some( self.input_username .get_text() - .clone(), + .to_string(), ), None, ); @@ -131,7 +131,7 @@ impl Component for CredComponent { Some( self.input_password .get_text() - .clone(), + .to_string(), ), ); self.input_password.hide(); diff --git a/src/components/rename_branch.rs b/src/components/rename_branch.rs index 4a7889d2..3171de8b 100644 --- a/src/components/rename_branch.rs +++ b/src/components/rename_branch.rs @@ -127,11 +127,8 @@ impl RenameBranchComponent { /// pub fn rename_branch(&mut self) { if let Some(br) = &self.branch_ref { - let res = sync::rename_branch( - CWD, - br, - self.input.get_text().as_str(), - ); + let res = + sync::rename_branch(CWD, br, self.input.get_text()); match res { Ok(_) => { diff --git a/src/components/stashmsg.rs b/src/components/stashmsg.rs index e7b1e979..b2af42a4 100644 --- a/src/components/stashmsg.rs +++ b/src/components/stashmsg.rs @@ -68,7 +68,7 @@ impl Component for StashMsgComponent { if self.input.get_text().is_empty() { None } else { - Some(self.input.get_text().as_str()) + Some(self.input.get_text()) }, self.options.stash_untracked, self.options.keep_index, diff --git a/src/components/textinput.rs b/src/components/textinput.rs index 072e5b49..a53dd258 100644 --- a/src/components/textinput.rs +++ b/src/components/textinput.rs @@ -81,8 +81,8 @@ impl TextInputComponent { } /// Get the `msg`. - pub const fn get_text(&self) -> &String { - &self.msg + pub fn get_text(&self) -> &str { + self.msg.as_str() } /// screen area (last time we got drawn)