Taking comments from #[doc] attributes?
kang-sw opened this issue · 2 comments
kang-sw commented
Thank you for developing a good crate. I'm finding it very useful. Could you please add an attribute to allow the automatically generated setter method to utilize the doc comment of the original struct field? Let it be like:
#[derive(Setters)]
struct MyStruct {
/// pewpew!
/// this is
/// my
/// comment!
my_var: u32,
}
// -- GENERATED --
impl MyStruct {
#[doc ="pewpew!"]
#[doc ="this is"]
#[doc ="my"]
#[doc ="comment!"]
pub fn set_my_var(mut self, value: u32) -> Self {
todo!()
}
}
Lymia commented
This happens by default if my_var
is private, and it only makes the "Sets the [...] field" doc comment if the field is already public (to avoid duplicating the documentation in a strange way. What behavior would you want exactly, just accept having duplicate documentation on both fields?
There's a few ways to handle this.
kang-sw commented
Ah, I got confused by deriving a structure with all fields declared as pub. The behavior seems to be fine as it is, sorry for the interruption.