Skip to content

Commit 4097542

Browse files
chore(sidekick): Remove unreachable code (#2603)
The specs that we currently support do not support repeated or map fields within a oneof. We don't need to generate code for those cases.
1 parent c1f0285 commit 4097542

File tree

2 files changed

+2
-39
lines changed

2 files changed

+2
-39
lines changed

internal/sidekick/internal/rust/templates/common/message.mustache

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -166,37 +166,6 @@ impl {{Codec.Name}} {
166166
self
167167
}
168168
{{/Singular}}
169-
{{#Repeated}}
170-
pub fn set_{{Codec.SetterName}}<T, V>(mut self, v: T) -> Self
171-
where
172-
T: std::iter::IntoIterator<Item = V>,
173-
V: std::convert::Into<{{{Codec.PrimitiveFieldType}}}>
174-
{
175-
use std::iter::Iterator;
176-
self.{{Group.Codec.FieldName}} = std::option::Option::Some(
177-
{{Group.Codec.QualifiedName}}::{{Codec.BranchName}}(
178-
v.into_iter().map(|i| i.into()).collect()
179-
)
180-
);
181-
self
182-
}
183-
{{/Repeated}}
184-
{{#Map}}
185-
pub fn set_{{Codec.SetterName}}<T, K, V>(mut self, v: T) -> Self
186-
where
187-
T: std::iter::IntoIterator<Item = (K, V)>,
188-
K: std::convert::Into<{{{Codec.KeyType}}}>,
189-
V: std::convert::Into<{{{Codec.ValueType}}}>,
190-
{
191-
use std::iter::Iterator;
192-
self.{{Group.Codec.FieldName}} = std::option::Option::Some(
193-
{{Group.Codec.QualifiedName}}::{{Codec.BranchName}}(
194-
v.into_iter().map(|(k, v)| (k.into(), v.into())).collect()
195-
)
196-
);
197-
self
198-
}
199-
{{/Map}}
200169
{{/Fields}}
201170
{{/OneOfs}}
202171
}

internal/sidekick/internal/rust/templates/common/setter_preamble/oneof_variants.mustache

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,17 @@ limitations under the License.
1919
/// Note that all the setters affecting `{{Group.Codec.FieldName}}` are
2020
/// mutually exclusive.
2121
{{#ModelCodec.GenerateSetterSamples}}
22+
{{#Singular}}
2223
///
2324
/// # Example
2425
/// ```
25-
{{#Singular}}
2626
{{> /templates/common/setter_preamble/singular_value_samples}}
27-
{{/Singular}}
28-
{{#Repeated}}
29-
{{> /templates/common/setter_preamble/repeated_samples}}
30-
{{/Repeated}}
31-
{{#Map}}
32-
{{> /templates/common/setter_preamble/map_samples}}
33-
{{/Map}}
3427
/// assert!(x.{{Codec.FieldName}}().is_some());
3528
{{#Codec.OtherFieldsInGroup}}
3629
/// assert!(x.{{Codec.FieldName}}().is_none());
3730
{{/Codec.OtherFieldsInGroup}}
3831
/// ```
32+
{{/Singular}}
3933
{{/ModelCodec.GenerateSetterSamples}}
4034
{{#Deprecated}}
4135
#[deprecated]

0 commit comments

Comments
 (0)