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

Unary tuple struct getter/setter #90

Open
Jasha10 opened this issue Jul 30, 2023 · 0 comments
Open

Unary tuple struct getter/setter #90

Jasha10 opened this issue Jul 30, 2023 · 0 comments

Comments

@Jasha10
Copy link

Jasha10 commented Jul 30, 2023

Currently getset seems to work with ordinary structs but not with tuple structs:

#[derive(getset::Getters)]
pub struct MyType(u64);
 1  error: Expected the field to have a name
    --> crates/entities/src/newtypes.rs:265:39
     |
 265 | pub struct NonNegativeTimeDeltaMicros(u64);

The following also fails:

#[derive(getset::Getters)]
pub struct MyType(#[getset(get)] u64);

Pitch

It would be convenient to derive get, set, etc for unary tuple structs.
This naming convention has precedent in the standard library. For example, we have std::num::NonZeroU64::get which returns the u64 type that is wrapped by the NonZeroU64 tuple struct.

@Jasha10 Jasha10 changed the title Handle unary tuple struct Unary tuple struct getter/setter Jul 30, 2023
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