Replace OpenOptions::new with File::options to be readable (#3059)

## Issue Addressed

Closes #3049 

This PR updates widely but this replace is safe as `File::options()` is equivelent to `OpenOptions::new()`.
ref: https://doc.rust-lang.org/stable/src/std/fs.rs.html#378-380
This commit is contained in:
Akihito Nakano
2022-03-07 06:30:18 +00:00
parent cbda0a2f0a
commit 4186d117af
16 changed files with 40 additions and 41 deletions

View File

@@ -2,7 +2,7 @@
use eth2_wallet::Error as WalletError;
use eth2_wallet::{Uuid, Wallet};
use std::fs::{copy as copy_file, remove_file, OpenOptions};
use std::fs::{copy as copy_file, remove_file, File};
use std::io;
use std::path::{Path, PathBuf};
@@ -27,7 +27,7 @@ pub fn read<P: AsRef<Path>>(wallet_dir: P, uuid: &Uuid) -> Result<Wallet, Error>
if !json_path.exists() {
Err(Error::WalletDoesNotExist(json_path))
} else {
OpenOptions::new()
File::options()
.read(true)
.create(false)
.open(json_path)
@@ -79,7 +79,7 @@ pub fn create<P: AsRef<Path>>(wallet_dir: P, wallet: &Wallet) -> Result<(), Erro
if json_path.exists() {
Err(Error::WalletAlreadyExists(json_path))
} else {
OpenOptions::new()
File::options()
.write(true)
.create_new(true)
.open(json_path)