mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-13 15:30:03 +00:00
Optimize: Create new fn helpers::cargo_home
that caches return value of `home::cargo_home` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
305a4e4c30
commit
21eac33e1f
3 changed files with 14 additions and 2 deletions
|
@ -10,6 +10,7 @@ use serde::{Deserialize, Serialize};
|
|||
use thiserror::Error;
|
||||
|
||||
use super::CrateVersionSource;
|
||||
use crate::cargo_home;
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct CratesToml {
|
||||
|
@ -18,7 +19,7 @@ pub struct CratesToml {
|
|||
|
||||
impl CratesToml {
|
||||
pub fn default_path() -> Result<PathBuf, CratesTomlParseError> {
|
||||
Ok(home::cargo_home()?.join(".crates.toml"))
|
||||
Ok(cargo_home()?.join(".crates.toml"))
|
||||
}
|
||||
|
||||
pub fn load() -> Result<Self, CratesTomlParseError> {
|
||||
|
|
|
@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
|
|||
use thiserror::Error;
|
||||
|
||||
use super::CrateVersionSource;
|
||||
use crate::cargo_home;
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct Crates2Json {
|
||||
|
@ -39,7 +40,7 @@ pub struct CrateInfo {
|
|||
|
||||
impl Crates2Json {
|
||||
pub fn default_path() -> Result<PathBuf, Crates2JsonParseError> {
|
||||
Ok(home::cargo_home()?.join(".crates2.json"))
|
||||
Ok(cargo_home()?.join(".crates2.json"))
|
||||
}
|
||||
|
||||
pub fn load() -> Result<Self, Crates2JsonParseError> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue