Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Derive
Eq
and Hash
wherever possible
In server SDKs, these traits can be implemented by any shape _except_ if the shape's closure contains: 1. A `float`, `double`, or `document` shape: floating point types in Rust do not implement `Eq`. Similarly, [`document` shapes] may contain arbitrary JSON-like data containing floating point values. 2. A [@streaming] shape: all the streaming data would need to be buffered first to compare it. Additionally, the `Hash` trait cannot be implemented by shapes whose closure contains: 1. A `map` shape: we render `map` shapes as `std::collections::HashMap`, which _do not_ implement `Hash`. See smithy-lang/smithy#1567. In **client SDKs, these traits cannot be derived on any code-generated Rust types corresponding to Smithy shapes**, since e.g. adding new optional members to a structure [is a backwards-compatible change], and doing so alters the semantics of these traits. However, this commit does implement these traits for the `aws_smithy_types::date_time::DateTime` and `aws_smithy_types::Blob` runtime types. This change is necessary to efficiently implement the `@uniqueItems` constraint trait in server SDKs. [`Eq`]: https://doc.rust-lang.org/std/cmp/trait.Eq.html [`Hash`]: https://doc.rust-lang.org/std/hash/trait.Hash.html [`document` shapes]: https://smithy.io/2.0/spec/simple-types.html#document [@streaming]: https://smithy.io/2.0/spec/streaming.html [is a backwards-compatible change]: https://smithy.io/2.0/guides/evolving-models.html#updating-structures
- Loading branch information