2023-12-16 07:12:50 -06:00
|
|
|
#![warn(clippy::ineffective_open_options)]
|
|
|
|
|
|
|
|
use std::fs::OpenOptions;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let file = OpenOptions::new()
|
|
|
|
.create(true)
|
|
|
|
.write(true) //~ ERROR: unnecessary use of `.write(true)`
|
|
|
|
.append(true)
|
|
|
|
.open("dump.json")
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let file = OpenOptions::new()
|
|
|
|
.create(true)
|
|
|
|
.append(true)
|
|
|
|
.write(true) //~ ERROR: unnecessary use of `.write(true)`
|
|
|
|
.open("dump.json")
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
// All the next calls are ok.
|
|
|
|
let file = OpenOptions::new()
|
|
|
|
.create(true)
|
|
|
|
.write(false)
|
|
|
|
.append(true)
|
|
|
|
.open("dump.json")
|
|
|
|
.unwrap();
|
|
|
|
let file = OpenOptions::new()
|
|
|
|
.create(true)
|
2024-01-25 12:17:36 -06:00
|
|
|
.truncate(true)
|
2023-12-16 07:12:50 -06:00
|
|
|
.write(true)
|
|
|
|
.append(false)
|
|
|
|
.open("dump.json")
|
|
|
|
.unwrap();
|
|
|
|
let file = OpenOptions::new()
|
|
|
|
.create(true)
|
2024-01-25 12:17:36 -06:00
|
|
|
.truncate(true)
|
2023-12-16 07:12:50 -06:00
|
|
|
.write(false)
|
|
|
|
.append(false)
|
|
|
|
.open("dump.json")
|
|
|
|
.unwrap();
|
|
|
|
let file = OpenOptions::new().create(true).append(true).open("dump.json").unwrap();
|
2024-01-25 12:17:36 -06:00
|
|
|
let file = OpenOptions::new()
|
|
|
|
.create(true)
|
|
|
|
.truncate(true)
|
|
|
|
.write(true)
|
|
|
|
.open("dump.json")
|
|
|
|
.unwrap();
|
2023-12-16 07:12:50 -06:00
|
|
|
}
|