use HashSet instead of Vec for file links
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::ffi::OsStr;
|
||||
use std::{collections::HashSet, ffi::OsStr};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::{
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||
pub struct InstalledMod {
|
||||
id: String,
|
||||
files: Vec<Link>,
|
||||
files: HashSet<Link>,
|
||||
priority: isize,
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ impl InstalledMod {
|
||||
pub fn new(root_mod_id: &str, priority: isize) -> Self {
|
||||
Self {
|
||||
id: root_mod_id.to_owned(),
|
||||
files: Vec::new(),
|
||||
files: HashSet::new(),
|
||||
priority,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_file(&mut self, file: &ModFile) {
|
||||
self.files.push(Link::from_mod_file(file));
|
||||
self.files.insert(Link::from_mod_file(file));
|
||||
}
|
||||
|
||||
/// Get the id of the mod
|
||||
@@ -38,7 +38,7 @@ impl InstalledMod {
|
||||
}
|
||||
|
||||
/// The selected files
|
||||
pub fn files(&self) -> &[Link] {
|
||||
pub fn files(&self) -> &HashSet<Link> {
|
||||
&self.files
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::types::mod_file::ModFile;
|
||||
|
||||
/// A link between a file from a mod and a destination in a ModdedInstance
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, Hash)]
|
||||
#[serde(from = "(PathBuf, PathBuf)", into = "(PathBuf,PathBuf)")]
|
||||
pub struct Link {
|
||||
src: PathBuf,
|
||||
|
||||
Reference in New Issue
Block a user