manifest: does moo
@@ -2,6 +2,7 @@ use crate::types::addons::ResourceRef;
use either::Either;
use semver::Version;
use serde_derive::*;
+use std::borrow::Cow;
// Resource descriptors
// those define how a resource may be requested
@@ -79,17 +80,21 @@ pub struct ManifestCatalog {
pub extra: ManifestExtra,
}
impl ManifestCatalog {
- pub fn extra_iter<'a>(&'a self) -> impl Iterator<Item = ManifestExtraProp> + 'a {
+ pub fn extra_iter<'a>(&'a self) -> impl Iterator<Item = Cow<ManifestExtraProp>> + 'a {
match &self.extra {
- ManifestExtra::Full { ref props } => Either::Left(props.iter().cloned()),
+ ManifestExtra::Full { ref props } => {
+ Either::Left(props.iter().map(|x| Cow::Borrowed(x)))
+ }
ManifestExtra::Short {
required,
supported,
- } => Either::Right(supported.iter().map(move |name| ManifestExtraProp {
+ } => Either::Right(supported.iter().map(move |name| {
+ Cow::Owned(ManifestExtraProp {
name: name.to_owned(),
is_required: required.contains(name),
options: None,
options_limit: Default::default(),
+ })
})),
}
}
