blob: 3af8f3c5aaa44d8c6cc4f1fce081df33d5238a62 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#![warn(clippy::ineffective_open_options)]
use std::fs::OpenOptions;
fn main() {
let file = OpenOptions::new()
.create(true)
//~ ERROR: unnecessary use of `.write(true)`
.append(true)
.open("dump.json")
.unwrap();
let file = OpenOptions::new()
.create(true)
.append(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)
.write(true)
.append(false)
.open("dump.json")
.unwrap();
let file = OpenOptions::new()
.create(true)
.write(false)
.append(false)
.open("dump.json")
.unwrap();
let file = OpenOptions::new().create(true).append(true).open("dump.json").unwrap();
let file = OpenOptions::new().create(true).write(true).open("dump.json").unwrap();
}
|