Skip to content

Commit 16ff327

Browse files
committed
Avoid File::create_new for compatibility with project MSRV
Besides the style change done in the previous commit, `clippy` also identified `File::create_new` is newer than we may wish to rely on: error: current MSRV (Minimum Supported Rust Version) is `1.76.0` but this item is stable since `1.77.0` --> tests/tools/src/lib.rs:906:13 | 906 | File::create_new(path) | ^^^^^^^^^^^^^^^^ This changes that code to use `OpenOptions` instead. This is simlar to the suggested equivalent code in the `File::create_new` documentation: File::options().read(true).write(true).create_new(true).open(...) But the approach used here differs in that `read(true)` is removed, since this call is only creating and writing, not reading.
1 parent 79c0930 commit 16ff327

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/tools/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,10 @@ mod tests {
903903

904904
// Create the files.
905905
for path in paths {
906-
File::create_new(path)
906+
File::options()
907+
.write(true)
908+
.create_new(true)
909+
.open(path)
907910
.expect("can create file")
908911
.write_all(CONFIG_DATA)
909912
.expect("can write contents");

0 commit comments

Comments
 (0)