Unverified Commit 02205ae1 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

feedback: noclone

parent 5f06f9f1
...@@ -94,25 +94,25 @@ impl Asset for StaticInfoManifestAsset { ...@@ -94,25 +94,25 @@ impl Asset for StaticInfoManifestAsset {
#[derive(Serialize)] #[derive(Serialize)]
#[serde(untagged)] #[serde(untagged)]
enum ManifestRegion { enum ManifestRegion<'a> {
Single(String), Single(&'a RcStr),
Multiple(Vec<String>), Multiple(&'a [RcStr]),
} }
#[derive(Serialize)] #[derive(Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct ManifestMiddleware { struct ManifestMiddleware<'a> {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub matchers: Option<Vec<ProxyMatcher>>, pub matchers: Option<Vec<ProxyMatcher>>,
#[serde( #[serde(
rename = "unstable_allowDynamic", rename = "unstable_allowDynamic",
skip_serializing_if = "Option::is_none" skip_serializing_if = "Option::is_none"
)] )]
pub unstable_allow_dynamic: Option<Vec<RcStr>>, pub unstable_allow_dynamic: &'a Option<Vec<RcStr>>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub regions: Option<ManifestRegion>, pub regions: Option<ManifestRegion<'a>>,
} }
impl ManifestMiddleware { impl ManifestMiddleware<'_> {
fn is_empty(&self) -> bool { fn is_empty(&self) -> bool {
self.matchers.is_none() self.matchers.is_none()
&& self.unstable_allow_dynamic.is_none() && self.unstable_allow_dynamic.is_none()
...@@ -126,7 +126,7 @@ impl Asset for StaticInfoManifestAsset { ...@@ -126,7 +126,7 @@ impl Asset for StaticInfoManifestAsset {
#[serde(rename = "type")] #[serde(rename = "type")]
ty: &'a str, ty: &'a str,
#[serde(skip_serializing_if = "ManifestMiddleware::is_empty")] #[serde(skip_serializing_if = "ManifestMiddleware::is_empty")]
middleware: ManifestMiddleware, middleware: ManifestMiddleware<'a>,
#[serde(skip_serializing_if = "std::ops::Not::not")] #[serde(skip_serializing_if = "std::ops::Not::not")]
generate_sitemaps: bool, generate_sitemaps: bool,
#[serde(skip_serializing_if = "std::ops::Not::not")] #[serde(skip_serializing_if = "std::ops::Not::not")]
...@@ -134,7 +134,7 @@ impl Asset for StaticInfoManifestAsset { ...@@ -134,7 +134,7 @@ impl Asset for StaticInfoManifestAsset {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
runtime: Option<NextRuntime>, runtime: Option<NextRuntime>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
preferred_region: Option<ManifestRegion>, preferred_region: Option<ManifestRegion<'a>>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
max_duration: Option<u32>, max_duration: Option<u32>,
} }
...@@ -144,10 +144,8 @@ impl Asset for StaticInfoManifestAsset { ...@@ -144,10 +144,8 @@ impl Asset for StaticInfoManifestAsset {
.preferred_region .preferred_region
.as_ref() .as_ref()
.map(|region| match region { .map(|region| match region {
NextSegmentRegion::Single(region) => ManifestRegion::Single(region.to_string()), NextSegmentRegion::Single(region) => ManifestRegion::Single(region),
NextSegmentRegion::Multiple(regions) => { NextSegmentRegion::Multiple(regions) => ManifestRegion::Multiple(regions),
ManifestRegion::Multiple(regions.iter().map(ToString::to_string).collect())
}
}); });
let (regions, preferred_region) = if self.ty.as_str() == "app" { let (regions, preferred_region) = if self.ty.as_str() == "app" {
(None, region) (None, region)
...@@ -162,7 +160,7 @@ impl Asset for StaticInfoManifestAsset { ...@@ -162,7 +160,7 @@ impl Asset for StaticInfoManifestAsset {
has_i18n_locales, has_i18n_locales,
base_path.as_deref(), base_path.as_deref(),
), ),
unstable_allow_dynamic: config.unstable_allow_dynamic.clone(), unstable_allow_dynamic: &config.unstable_allow_dynamic,
regions, regions,
}, },
runtime: config.entry.runtime, runtime: config.entry.runtime,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment