summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/context.rs3
-rw-r--r--src/formatter/string_formatter.rs5
-rw-r--r--src/init/mod.rs2
-rw-r--r--src/lib.rs2
-rw-r--r--src/main.rs2
-rw-r--r--src/module.rs5
-rw-r--r--src/modules/custom.rs2
-rw-r--r--src/modules/docker_context.rs6
-rw-r--r--src/modules/pulumi.rs2
-rw-r--r--src/modules/status.rs12
-rw-r--r--src/utils.rs2
11 files changed, 22 insertions, 21 deletions
diff --git a/src/context.rs b/src/context.rs
index 952b48a12..1511aadee 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -475,16 +475,19 @@ pub struct ScanDir<'a> {
}
impl<'a> ScanDir<'a> {
+ #[must_use]
pub const fn set_files(mut self, files: &'a [&'a str]) -> Self {
self.files = files;
self
}
+ #[must_use]
pub const fn set_extensions(mut self, extensions: &'a [&'a str]) -> Self {
self.extensions = extensions;
self
}
+ #[must_use]
pub const fn set_folders(mut self, folders: &'a [&'a str]) -> Self {
self.folders = folders;
self
diff --git a/src/formatter/string_formatter.rs b/src/formatter/string_formatter.rs
index fb890b29f..730e22f07 100644
--- a/src/formatter/string_formatter.rs
+++ b/src/formatter/string_formatter.rs
@@ -111,6 +111,7 @@ impl<'a> StringFormatter<'a> {
///
/// - `Some(Ok(_))`: The value of this variable will be displayed in the format string.
///
+ #[must_use]
pub fn map<T, M>(mut self, mapper: M) -> Self
where
T: Into<Cow<'a, str>>,
@@ -131,6 +132,7 @@ impl<'a> StringFormatter<'a> {
///
/// See `StringFormatter::map` for description on the parameters.
///
+ #[must_use]
pub fn map_no_escaping<T, M>(mut self, mapper: M) -> Self
where
T: Into<Cow<'a, str>>,
@@ -152,6 +154,7 @@ impl<'a> StringFormatter<'a> {
/// the format strings of meta-variables can be cached properly.
///
/// See `StringFormatter::map` for description on the parameters.
+ #[must_use]
pub fn map_meta<M>(mut self, mapper: M) -> Self
where
M: Fn(&str, &BTreeSet<String>) -> Option<&'a str> + Sync,
@@ -193,6 +196,7 @@ impl<'a> StringFormatter<'a> {
/// Maps variable name to an array of segments
///
/// See `StringFormatter::map` for description on the parameters.
+ #[must_use]
pub fn map_variables_to_segments<M>(mut self, mapper: M) -> Self
where
M: Fn(&str) -> Option<Result<Vec<Segment>, StringFormatterError>> + Sync,
@@ -209,6 +213,7 @@ impl<'a> StringFormatter<'a> {
/// Maps variable name in a style string to its value
///
/// See `StringFormatter::map` for description on the parameters.
+ #[must_use]
pub fn map_style<T, M>(mut self, mapper: M) -> Self
where
T: Into<Cow<'a, str>>,
diff --git a/src/init/mod.rs b/src/init/mod.rs
index 9131ef682..477f1c0d3 100644
--- a/src/init/mod.rs
+++ b/src/init/mod.rs
@@ -43,7 +43,7 @@ impl StarshipPath {
/// PowerShell specific path escaping
fn sprint_pwsh(&self) -> io::Result<String> {
self.str_path()
- .map(|s| s.replace("'", "''"))
+ .map(|s| s.replace('\'', "''"))
.map(|s| format!("'{}'", s))
}
/// Command Shell specific path escaping
diff --git a/src/lib.rs b/src/lib.rs
index 8329f389d..52c719739 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,4 @@
-#![warn(clippy::disallowed_method)]
+#![warn(clippy::disallowed_methods)]
#[macro_use]
extern crate shadow_rs;
diff --git a/src/main.rs b/src/main.rs
index fd0176630..8362ec6c9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,4 @@
-#![warn(clippy::disallowed_method)]
+#![warn(clippy::disallowed_methods)]
use clap::crate_authors;
use std::io;
diff --git a/src/module.rs b/src/module.rs
index 65a1d67f7..2b1da5068 100644
--- a/src/module.rs
+++ b/src/module.rs
@@ -209,8 +209,7 @@ where
current
} else {
let fill_size = term_width
- .map(|tw| if tw > used { Some(tw - used) } else { None })
- .flatten()
+ .and_then(|tw| if tw > used { Some(tw - used) } else { None })
.map(|remaining| remaining / chunks.len());
chunks
.into_iter()
@@ -229,7 +228,7 @@ mod tests {
#[test]
fn test_all_modules_is_in_alphabetical_order() {
- let mut sorted_modules: Vec<&str> = ALL_MODULES.iter().copied().collect();
+ let mut sorted_modules: Vec<&str> = ALL_MODULES.to_vec();
sorted_modules.sort_unstable();
assert_eq!(sorted_modules.as_slice(), ALL_MODULES);
}
diff --git a/src/modules/custom.rs b/src/modules/custom.rs
index c326323c6..309129cdd 100644
--- a/src/modules/custom.rs
+++ b/src/modules/custom.rs
@@ -123,7 +123,7 @@ fn shell_command(cmd: &str, shell_args: &[&str]) -> Option<Output> {
"Could not launch command with given shell or STARSHIP_SHELL env variable, retrying with /usr/bin/env sh"
);
- #[allow(clippy::disallowed_method)]
+ #[allow(clippy::disallowed_methods)]
Command::new("/usr/bin/env")
.arg("sh")
.stdin(Stdio::piped())
diff --git a/src/modules/docker_context.rs b/src/modules/docker_context.rs
index ff0a048f2..80ed4bfed 100644
--- a/src/modules/docker_context.rs
+++ b/src/modules/docker_context.rs
@@ -41,9 +41,9 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
)
.join("config.json");
- let docker_context_env =
- std::array::IntoIter::new(["DOCKER_MACHINE_NAME", "DOCKER_HOST", "DOCKER_CONTEXT"])
- .find_map(|env| context.get_env(env));
+ let docker_context_env = ["DOCKER_MACHINE_NAME", "DOCKER_HOST", "DOCKER_CONTEXT"]
+ .into_iter()
+ .find_map(|env| context.get_env(env));
let ctx = match docker_context_env {
Some(data) => data,
diff --git a/src/modules/pulumi.rs b/src/modules/pulumi.rs
index 7329008d0..7cbf3ccb6 100644
--- a/src/modules/pulumi.rs
+++ b/src/modules/pulumi.rs
@@ -158,7 +158,7 @@ fn get_pulumi_workspace(context: &Context, name: &str, project_file: &Path) -> O
} else {
let mut hasher = Sha1::new();
hasher.update(project_file.to_str()?.as_bytes());
- crate::utils::encode_to_hex(&hasher.finalize().to_vec())
+ crate::utils::encode_to_hex(&hasher.finalize())
};
let unique_file_name = format!("{}-{}-workspace.json", name, project_file);
let mut path = pulumi_home_dir(context)?;
diff --git a/src/modules/status.rs b/src/modules/status.rs
index d7299c0dd..a3ae4fea9 100644
--- a/src/modules/status.rs
+++ b/src/modules/status.rs
@@ -76,13 +76,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
PipeStatusStatus::Pipe(_) => config.pipestatus_format,
_ => config.format,
};
- let parsed = format_exit_code(
- &exit_code.to_string(),
- main_format,
- Some(&pipestatus),
- &config,
- context,
- );
+ let parsed = format_exit_code(exit_code, main_format, Some(&pipestatus), &config, context);
module.set_segments(match parsed {
Ok(segments) => segments,
@@ -119,8 +113,8 @@ fn format_exit_code<'a>(
false => None,
};
let signal_number = raw_signal_number.map(|sn| sn.to_string());
- let signal_name = raw_signal_number
- .and_then(|sn| status_signal_name(sn).or_else(|| signal_number.as_deref()));
+ let signal_name =
+ raw_signal_number.and_then(|sn| status_signal_name(sn).or(signal_number.as_deref()));
// If not a signal and not a common meaning, it should at least print the raw exit code number
let maybe_exit_code_number = match common_meaning.is_none() && signal_name.is_none() {
diff --git a/src/utils.rs b/src/utils.rs
index 6ef8299c9..4205b5a95 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -75,7 +75,7 @@ pub fn create_command<T: AsRef<OsStr>>(binary_name: T) -> Result<Command> {
}
};
- #[allow(clippy::disallowed_method)]
+ #[allow(clippy::disallowed_methods)]
let mut cmd = Command::new(full_path);
cmd.stderr(Stdio::piped())
.stdout(Stdio::piped())