mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-07-22 05:55:15 +08:00
refactor: reduce quality findings
This commit is contained in:
@@ -23,19 +23,23 @@ impl AddressablesCatalogDriver {
|
||||
}
|
||||
|
||||
fn locator_id(json: &Value) -> Option<String> {
|
||||
json.get("m_LocatorId")
|
||||
let locator = json
|
||||
.get("m_LocatorId")
|
||||
.and_then(|value| value.as_str())
|
||||
.map(ToOwned::to_owned)
|
||||
.map(ToOwned::to_owned);
|
||||
locator
|
||||
}
|
||||
|
||||
fn cdn_prefixes(json: &Value) -> Vec<String> {
|
||||
json.get("m_InternalIdPrefixes")
|
||||
let prefixes = json
|
||||
.get("m_InternalIdPrefixes")
|
||||
.and_then(|value| value.as_array())
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(|value| value.as_str())
|
||||
.map(ToOwned::to_owned)
|
||||
.collect()
|
||||
.collect();
|
||||
prefixes
|
||||
}
|
||||
|
||||
fn resource_type_for_path(path: &str) -> ResourceType {
|
||||
@@ -49,7 +53,8 @@ impl AddressablesCatalogDriver {
|
||||
}
|
||||
|
||||
fn resources(json: &Value) -> Vec<ResourceEntry> {
|
||||
json.get("m_InternalIds")
|
||||
let resources = json
|
||||
.get("m_InternalIds")
|
||||
.and_then(|value| value.as_array())
|
||||
.into_iter()
|
||||
.flatten()
|
||||
@@ -67,7 +72,8 @@ impl AddressablesCatalogDriver {
|
||||
resource_type: Self::resource_type_for_path(path),
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
.collect();
|
||||
resources
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user