Conversation
src/lib.rs
Outdated
| extern crate getset; | ||
|
|
||
| #[derive(Getters, Setters, MutGetters, Default)] | ||
| #[get = "pub"] #[set = "pub"] #[get_mut = "pub"] |
There was a problem hiding this comment.
Can you instead add another example that explicitly describes how the struct-level option interacts with field level options. I think this can highlight the feature and caveats better.
There was a problem hiding this comment.
I think compile_fail example perfect for that
| assert_eq!(*foo.private(), 2); | ||
| } | ||
| ``` | ||
| ```compile_fail |
There was a problem hiding this comment.
This needs some related documentation or something. :)
There was a problem hiding this comment.
Added documentation about struct level atrributes here
There was a problem hiding this comment.
Functionally, it seems to make sense that this could work without erroring. If the field attributes take precedence can we implement them and not the struct level value, instead of erroring? It seems like a more flexible API.
If not, I think the compile_fail could be reduced to this:
#[derive(Getters, Default)]
#[get = "pub"]
pub struct Foo {
#[get] // Invalid!
private: i32,
public: i32,
}Then maybe we can have a full, valid example of the struct level attributes and field level working?
Sorry to be such a stickler about this. 🤣
There was a problem hiding this comment.
It's compile_fail test not because we cannot mix struct and field level attributes. It's fine.
But generated getter is private, and we try to call it and this is compile time error.
I clarify this is with comment
Sorry to be such a stickler about this
It's fine
Signed-off-by: Marat Safin <jeizsm@gmail.com>
Signed-off-by: Marat Safin <jeizsm@gmail.com>
|
Closing in favor of #24. :) |
|
This feature is now merged, thanks for the contribution! |
Handle struct attribute. So it is not needed to add attribute to every field in struct, what can be cumbersome in big structs.
And multiple refactors to remove duplication mostly