Refactor hydrus service

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/6/head
trivernis 3 years ago
parent 27ec3b98f0
commit 68a6d00c4c
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -4,6 +4,7 @@ use crate::api_core::access_management::{
SERVICE_TYPE_FILE_REPOSITORIES, SERVICE_TYPE_LOCAL_FILES, SERVICE_TYPE_LOCAL_TAGS, SERVICE_TYPE_FILE_REPOSITORIES, SERVICE_TYPE_LOCAL_FILES, SERVICE_TYPE_LOCAL_TAGS,
SERVICE_TYPE_TAG_REPOSITORIES, SERVICE_TYPE_TRASH, SERVICE_TYPE_TAG_REPOSITORIES, SERVICE_TYPE_TRASH,
}; };
use crate::error::Error; use crate::error::Error;
use crate::Client; use crate::Client;
use std::collections::HashMap; use std::collections::HashMap;
@ -140,13 +141,9 @@ impl Services {
/// Returns a list of all services of the given type /// Returns a list of all services of the given type
pub fn get_services(&self, service_type: ServiceType) -> Vec<&Service> { pub fn get_services(&self, service_type: ServiceType) -> Vec<&Service> {
if let Some(services) = self.inner.get(&service_type) { if let Some(services) = self.inner.get(&service_type) {
let mut borrowed_services = Vec::with_capacity(services.len()); services.into_iter().collect()
for service in services {
borrowed_services.push(service)
}
borrowed_services
} else { } else {
Vec::with_capacity(0) Vec::new()
} }
} }
} }

Loading…
Cancel
Save