Skip to content

Conversation

@ramosbugs
Copy link

What did you implement:

Previously, #[derive(Attribute)] only supported enums. This PR adds support for newtype structs as well (i.e., single-field tuple structs containing another Attribute type):

#[derive(Attribute)]
struct Author(String); // <-- `Author` transparently wraps `String` (zero-cost abstraction)

#[derive(Item)]
struct Book {
    #[dynomite(partition_key)]
    id: String,
    author: Author,
}

This functionality mirrors serde's behavior.

How did you verify your change:

Added docs and a couple of test cases.

What (if anything) would need to be called out in the CHANGELOG for the next release:

No breaking changes; just a small new feature.

@ramosbugs
Copy link
Author

ramosbugs commented Dec 16, 2020

I see this is addressed in #139 :-)
looks like clippy is unhappy about self: Self in a bunch of (existing) places:

error: the type of the `self` parameter does not need to be arbitrary
Error:    --> dynomite/src/lib.rs:912:18
    |
912 |     fn into_attr(self: Self) -> AttributeValue {
    |                  ^^^^^^^^^^ help: consider to change this parameter to: `self`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_arbitrary_self_type

I can remove the : Self instances if you'd like

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

Successfully merging this pull request may close these issues.

1 participant