You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The implementation for unnamed enums should do the same, but doesn't.
Example:
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT./// Targets represent instances in underlying systems, like packages, code deploy apps, etc.#[non_exhaustive]#[derive(::std::clone::Clone,::std::cmp::Eq,::std::cmp::Ord,::std::cmp::PartialEq,::std::cmp::PartialOrd,::std::fmt::Debug,::std::hash::Hash,)]pubstructTargetType(String);implTargetType{/// Returns the `&str` value of the enum member.pubfnas_str(&self) -> &str{&self.0}/// Returns all the `&str` representations of the enum members.pubconstfnvalues() -> &'static [&'static str]{&["BATS","CD","CF","DG","ENV","GEN","OS","PKG","VS"]}}impl::std::str::FromStrforTargetType{typeErr = ::std::convert::Infallible;fnfrom_str(s:&str) -> ::std::result::Result<Self, <Selfas::std::str::FromStr>::Err>{::std::result::Result::Ok(TargetType::from(s))}}impl<T>::std::convert::From<T>forTargetTypewhereT:::std::convert::AsRef<str>,{fnfrom(s:T) -> Self{TargetType(s.as_ref().to_owned())}}
This causes generated clients for models that use these unnamed enums in url path or query parameters to not build due to the AsRef<str> binding here:
This conflict occurs because implementing AsRef<str> for TargetType would make TargetType itself eligible for our blanket implementation impl<T> From<T> for TargetType (since it would now implement AsRef<str>). This conflicts with the built-in blanket implementation in the core crate that allows converting a type into itself.
As a workaround, you can use the existing .as_str() method on unnamed enums to get a string reference when needed.
The generated code for named enums includes an
AsRef<str>
implementation that defers toSelf::as_str
.smithy-rs/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/EnumGenerator.kt
Lines 217 to 226 in 4b66264
Example:
The implementation for unnamed enums should do the same, but doesn't.
Example:
This causes generated clients for models that use these unnamed enums in url path or query parameters to not build due to the
AsRef<str>
binding here:smithy-rs/rust-runtime/aws-smithy-http/src/query.rs
Lines 16 to 19 in 4b66264
The text was updated successfully, but these errors were encountered: