Skip to content

Commit eb5601f

Browse files
djcrami3l
authored andcommitted
Move if_not_empty() to calling module
1 parent 2e438b0 commit eb5601f

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/config.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl<'a> Cfg<'a> {
291291
let env_override = process
292292
.var("RUSTUP_TOOLCHAIN")
293293
.ok()
294-
.and_then(utils::if_not_empty)
294+
.and_then(if_not_empty)
295295
.map(ResolvableLocalToolchainName::try_from)
296296
.transpose()?
297297
.map(|t| t.resolve(&default_host_triple))
@@ -307,7 +307,7 @@ impl<'a> Cfg<'a> {
307307
process
308308
.var("RUSTUP_DIST_ROOT")
309309
.ok()
310-
.and_then(utils::if_not_empty)
310+
.and_then(if_not_empty)
311311
.inspect(|url| trace!("`RUSTUP_DIST_ROOT` has been set to `{url}`"))
312312
.map_or(Cow::Borrowed(dist::DEFAULT_DIST_ROOT), Cow::Owned)
313313
.as_ref()
@@ -1000,6 +1000,14 @@ fn get_default_host_triple(s: &Settings, process: &Process) -> dist::TargetTripl
10001000
.unwrap_or_else(|| dist::TargetTriple::from_host_or_build(process))
10011001
}
10021002

1003+
fn if_not_empty<S: PartialEq<str>>(s: S) -> Option<S> {
1004+
if s == *"" {
1005+
None
1006+
} else {
1007+
Some(s)
1008+
}
1009+
}
1010+
10031011
fn no_toolchain_error(process: &Process) -> anyhow::Error {
10041012
RustupError::ToolchainNotSelected(process.name().unwrap_or_else(|| "Rust".into())).into()
10051013
}

src/utils/raw.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ pub(crate) fn random_string(length: usize) -> String {
6565
.collect()
6666
}
6767

68-
pub(crate) fn if_not_empty<S: PartialEq<str>>(s: S) -> Option<S> {
69-
if s == *"" {
70-
None
71-
} else {
72-
Some(s)
73-
}
74-
}
75-
7668
pub fn write_file(path: &Path, contents: &str) -> io::Result<()> {
7769
let mut file = fs::OpenOptions::new()
7870
.write(true)

src/utils/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::utils::raw;
1717

1818
#[cfg(not(windows))]
1919
pub(crate) use crate::utils::utils::raw::find_cmd;
20-
pub(crate) use crate::utils::utils::raw::{if_not_empty, is_directory};
20+
pub(crate) use crate::utils::utils::raw::is_directory;
2121

2222
pub use crate::utils::utils::raw::{is_file, path_exists};
2323

0 commit comments

Comments
 (0)