From 6b4e70a32397ae541138a48bec88075493247ee6 Mon Sep 17 00:00:00 2001 From: Ramsay Leung Date: Sun, 24 Mar 2024 11:32:34 -0700 Subject: [PATCH 1/2] [fix]Fix the suspicious use of OpenOptions::create() without an explicit OpenOptions::truncate(). https://rust-lang.github.io/rust-clippy/master/index.html#/suspicious_open_options --- rspotify-model/src/auth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rspotify-model/src/auth.rs b/rspotify-model/src/auth.rs index e48cdfd4..034e34a0 100644 --- a/rspotify-model/src/auth.rs +++ b/rspotify-model/src/auth.rs @@ -69,7 +69,7 @@ impl Token { pub fn write_cache>(&self, path: T) -> ModelResult<()> { let token_info = serde_json::to_string(&self)?; - let mut file = fs::OpenOptions::new().write(true).create(true).open(path)?; + let mut file = fs::OpenOptions::new().write(true).create(true).truncate(true).open(path)?; file.set_len(0)?; file.write_all(token_info.as_bytes())?; From cb1965ceb5a63e1680e100fd88eb0d2dd835d47a Mon Sep 17 00:00:00 2001 From: Ramsay Leung Date: Sun, 24 Mar 2024 11:36:43 -0700 Subject: [PATCH 2/2] `cargo fmt` the codebase to respect the code taste. --- rspotify-model/src/auth.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rspotify-model/src/auth.rs b/rspotify-model/src/auth.rs index 034e34a0..d21c6607 100644 --- a/rspotify-model/src/auth.rs +++ b/rspotify-model/src/auth.rs @@ -69,7 +69,11 @@ impl Token { pub fn write_cache>(&self, path: T) -> ModelResult<()> { let token_info = serde_json::to_string(&self)?; - let mut file = fs::OpenOptions::new().write(true).create(true).truncate(true).open(path)?; + let mut file = fs::OpenOptions::new() + .write(true) + .create(true) + .truncate(true) + .open(path)?; file.set_len(0)?; file.write_all(token_info.as_bytes())?;