Enum aws_sdk_lexmodelsv2::model::SlotShape
source · #[non_exhaustive]
pub enum SlotShape {
List,
Scalar,
Unknown(UnknownVariantValue),
}Expand description
When writing a match expression against SlotShape, it is important to ensure
your code is forward-compatible. That is, if a match arm handles a case for a
feature that is supported by the service but has not been represented as an enum
variant in a current version of SDK, your code should continue to work when you
upgrade SDK to a future version in which the enum does include a variant for that
feature.
Here is an example of how you can make a match expression forward-compatible:
# let slotshape = unimplemented!();
match slotshape {
SlotShape::List => { /* ... */ },
SlotShape::Scalar => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when slotshape represents
NewFeature, the execution path will lead to the second last match arm,
even though the enum does not contain a variant SlotShape::NewFeature
in the current version of SDK. The reason is that the variable other,
created by the @ operator, is bound to
SlotShape::Unknown(UnknownVariantValue("NewFeature".to_owned()))
and calling as_str on it yields "NewFeature".
This match expression is forward-compatible when executed with a newer
version of SDK where the variant SlotShape::NewFeature is defined.
Specifically, when slotshape represents NewFeature,
the execution path will hit the second last match arm as before by virtue of
calling as_str on SlotShape::NewFeature also yielding "NewFeature".
Explicitly matching on the Unknown variant should
be avoided for two reasons:
- The inner data
UnknownVariantValueis opaque, and no further information can be extracted. - It might inadvertently shadow other intended match arms.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
List
Scalar
Unknown(UnknownVariantValue)
Unknown contains new variants that have been added since this code was generated.
Implementations§
source§impl SlotShape
impl SlotShape
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the &str value of the enum member.
Examples found in repository?
More examples
3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822
pub fn serialize_structure_crate_model_slot_value_override(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::SlotValueOverride,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_751) = &input.shape {
object.key("shape").string(var_751.as_str());
}
if let Some(var_752) = &input.value {
#[allow(unused_mut)]
let mut object_753 = object.key("value").start_object();
crate::json_ser::serialize_structure_crate_model_slot_value(&mut object_753, var_752)?;
object_753.finish();
}
if let Some(var_754) = &input.values {
let mut array_755 = object.key("values").start_array();
for item_756 in var_754 {
{
#[allow(unused_mut)]
let mut object_757 = array_755.value().start_object();
crate::json_ser::serialize_structure_crate_model_slot_value_override(
&mut object_757,
item_756,
)?;
object_757.finish();
}
}
array_755.finish();
}
Ok(())
}Trait Implementations§
source§impl Ord for SlotShape
impl Ord for SlotShape
source§impl PartialOrd<SlotShape> for SlotShape
impl PartialOrd<SlotShape> for SlotShape
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Eq for SlotShape
impl StructuralEq for SlotShape
impl StructuralPartialEq for SlotShape
Auto Trait Implementations§
impl RefUnwindSafe for SlotShape
impl Send for SlotShape
impl Sync for SlotShape
impl Unpin for SlotShape
impl UnwindSafe for SlotShape
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.