&str instead of weird &String

This commit is contained in:
Stephan Dilly 2021-09-02 19:19:09 +02:00
parent 6f2157c1d8
commit aaf0e4cfbf
6 changed files with 9 additions and 13 deletions

View File

@ -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)
}

View File

@ -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();

View File

@ -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();

View File

@ -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(_) => {

View File

@ -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,

View File

@ -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)