Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Eq and Hash trait for Tag for usage in HashSet. #1986

Open
VladasZ opened this issue Jun 22, 2022 · 0 comments
Open

Implement Eq and Hash trait for Tag for usage in HashSet. #1986

VladasZ opened this issue Jun 22, 2022 · 0 comments

Comments

@VladasZ
Copy link

VladasZ commented Jun 22, 2022

AWS doesn't allow duplicated tags and will fail with error if we try to add it:
<Code>InvalidParameterValue</Code><Message>Duplicate tag key 'tag:tag' specified.</Message>

It would be much more convenient to store tags in HashSet. But rusoto Tag doesn't implement Eq and Hash trait:

/// <p>Describes a tag.</p>
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serialize_structs", derive(Serialize))]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct Tag {
    /// <p>The key of the tag.</p> <p>Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin with <code>aws:</code>.</p>
    pub key: Option<String>,
    /// <p>The value of the tag.</p> <p>Constraints: Tag values are case-sensitive and accept a maximum of 255 Unicode characters.</p>
    pub value: Option<String>,
}

Now in my code I have to use vector and write additional checks for duplicated tags. Is it possible to add Eq and Hash implementation for Tag structure?

https://doc.rust-lang.org/std/collections/struct.HashSet.html

HashSet requires that the elements implement the Eq and Hash traits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant