mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 05:28:42 +00:00
Optimize CratesToml
: Use Vec
instead of BTreeSet
for storing bins. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
e86239f9be
commit
03c8295cd8
2 changed files with 6 additions and 7 deletions
|
@ -1,4 +1,3 @@
|
|||
use std::collections::BTreeSet;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::{metafiles, DesiredTargets, PkgOverride};
|
||||
|
@ -20,7 +19,7 @@ pub struct Options {
|
|||
|
||||
/// MetaData required to update MetaFiles.
|
||||
pub struct MetaData {
|
||||
pub bins: BTreeSet<String>,
|
||||
pub bins: Vec<String>,
|
||||
pub cvs: metafiles::CrateVersionSource,
|
||||
pub version_req: String,
|
||||
pub target: String,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
collections::BTreeMap,
|
||||
fs::File,
|
||||
io::{self, Seek},
|
||||
iter::IntoIterator,
|
||||
|
@ -15,7 +15,7 @@ use crate::{cargo_home, create_if_not_exist, FileLock};
|
|||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct CratesToml {
|
||||
v1: BTreeMap<String, BTreeSet<String>>,
|
||||
v1: BTreeMap<String, Vec<String>>,
|
||||
}
|
||||
|
||||
impl CratesToml {
|
||||
|
@ -38,7 +38,7 @@ impl CratesToml {
|
|||
Self::load_from_reader(file)
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, cvs: &CrateVersionSource, bins: BTreeSet<String>) {
|
||||
pub fn insert(&mut self, cvs: &CrateVersionSource, bins: Vec<String>) {
|
||||
self.v1.insert(cvs.to_string(), bins);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ impl CratesToml {
|
|||
iter: Iter,
|
||||
) -> Result<(), CratesTomlParseError>
|
||||
where
|
||||
Iter: IntoIterator<Item = (&'a CrateVersionSource, BTreeSet<String>)>,
|
||||
Iter: IntoIterator<Item = (&'a CrateVersionSource, Vec<String>)>,
|
||||
{
|
||||
let mut file = FileLock::new_exclusive(create_if_not_exist(path.as_ref())?)?;
|
||||
let mut c1 = Self::load_from_reader(&mut *file)?;
|
||||
|
@ -87,7 +87,7 @@ impl CratesToml {
|
|||
|
||||
pub fn append<'a, Iter>(iter: Iter) -> Result<(), CratesTomlParseError>
|
||||
where
|
||||
Iter: IntoIterator<Item = (&'a CrateVersionSource, BTreeSet<String>)>,
|
||||
Iter: IntoIterator<Item = (&'a CrateVersionSource, Vec<String>)>,
|
||||
{
|
||||
Self::append_to_path(Self::default_path()?, iter)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue