mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-07 12:40:04 +00:00
Minor Optimization and fix for bintalk-manifests
(#643)
* Optimize `CratesToml::load_from_reader`: Avoid dup monomorphization * Optimize `CratesToml::write_to_writer`: Avoid dup monomophization * Optimize `create_if_not_exist`: Take `&path` to avoid dup monomorphization * Fix `CratesToml::write_to_path`: Use exclusive file lock to prevent race conditions. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
959b465d81
commit
d4da4680f6
2 changed files with 22 additions and 13 deletions
|
@ -1,9 +1,7 @@
|
|||
use std::{fs, io, path::Path};
|
||||
|
||||
/// Returned file is readable and writable.
|
||||
pub(crate) fn create_if_not_exist(path: impl AsRef<Path>) -> io::Result<fs::File> {
|
||||
let path = path.as_ref();
|
||||
|
||||
pub(crate) fn create_if_not_exist(path: &Path) -> io::Result<fs::File> {
|
||||
let mut options = fs::File::options();
|
||||
options.read(true).write(true);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue