style: updated core dependency style

This commit is contained in:
Observer KRypt0n_ 2023-03-25 11:10:55 +02:00
parent 912e61e912
commit 7fc9b9ddba
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
3 changed files with 9 additions and 22 deletions

View file

@ -6,9 +6,12 @@ license = "GPL-3.0"
readme = "README.md"
edition = "2021"
[dependencies]
anime-game-core = { git = "https://github.com/an-anime-team/anime-game-core", tag = "1.4.5", features = ["genshin", "all"] }
[dependencies.anime-game-core]
git = "https://github.com/an-anime-team/anime-game-core"
tag = "1.4.5"
features = ["genshin", "all"]
[dependencies]
anyhow = "1.0"
dirs = "5.0.0"
tracing = "0.1"

View file

@ -32,7 +32,7 @@ impl Group {
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Features {
/// Standard environment variables that are applied when you launch the game
///
@ -45,14 +45,6 @@ pub struct Features {
pub env: HashMap<String, String>
}
impl Default for Features {
fn default() -> Self {
Self {
env: HashMap::new()
}
}
}
impl From<&JsonValue> for Features {
fn from(value: &JsonValue) -> Self {
let mut default = Self::default();
@ -161,9 +153,7 @@ pub fn get_downloaded<T: Into<PathBuf>>(components: T, folder: T) -> anyhow::Res
let folder: PathBuf = folder.into();
for mut group in get_groups(components)? {
group.versions = group.versions.into_iter()
.filter(|version| folder.join(&version.name).exists())
.collect();
group.versions.retain(|version| folder.join(&version.name).exists());
if !group.versions.is_empty() {
downloaded.push(group);

View file

@ -190,12 +190,8 @@ impl Version {
self.features.clone()
}
else if let Some(features) = &group.features {
Some(features.to_owned())
}
else {
None
group.features.as_ref().map(|features| features.to_owned())
}
}
@ -376,9 +372,7 @@ pub fn get_downloaded<T: Into<PathBuf>>(components: T, folder: T) -> anyhow::Res
let folder: PathBuf = folder.into();
for mut group in get_groups(components)? {
group.versions = group.versions.into_iter()
.filter(|version| folder.join(&version.name).exists())
.collect();
group.versions.retain(|version| folder.join(&version.name).exists());
if !group.versions.is_empty() {
downloaded.push(group);