diff options
author | 林炳权 <695601626@qq.com> | 2023-10-06 02:49:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-05 14:49:09 -0400 |
commit | 7a01799f490739612be27725f1584a995f6b1491 (patch) | |
tree | f7861a6db6d055ed109281533786046ad44c4eb8 /cli/util/fs.rs | |
parent | ab3c9d41e483e5a7e6a326c66af7052a51301f91 (diff) |
chore: update to Rust 1.73 (#20781)
Diffstat (limited to 'cli/util/fs.rs')
-rw-r--r-- | cli/util/fs.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cli/util/fs.rs b/cli/util/fs.rs index 93403659a..9aeeb62cc 100644 --- a/cli/util/fs.rs +++ b/cli/util/fs.rs @@ -9,6 +9,7 @@ use deno_runtime::deno_crypto::rand; use deno_runtime::deno_node::PathClean; use std::borrow::Cow; use std::env::current_dir; +use std::fmt::Write as FmtWrite; use std::fs::OpenOptions; use std::io::Error; use std::io::ErrorKind; @@ -57,9 +58,10 @@ pub fn atomic_write_file<T: AsRef<[u8]>>( fn inner(file_path: &Path, data: &[u8], mode: u32) -> std::io::Result<()> { let temp_file_path = { - let rand: String = (0..4) - .map(|_| format!("{:02x}", rand::random::<u8>())) - .collect(); + let rand: String = (0..4).fold(String::new(), |mut output, _| { + let _ = write!(output, "{:02x}", rand::random::<u8>()); + output + }); let extension = format!("{rand}.tmp"); file_path.with_extension(extension) }; |