Closed
Description
Given
struct S {
a$0: u8,
}
the "Generate getter/setter" assist can generate the following 3 methods:
impl S {
/// Get a mutable reference to the s's a.
#[must_use]
fn a_mut(&mut self) -> &mut u8 {
&mut self.a
}
/// Set the s's a.
fn set_a(&mut self, a: u8) {
self.a = a;
}
/// Get the s's a.
#[must_use]
fn a(&self) -> u8 {
self.a
}
}
However, there's no configuration for how these should look, so we impose some odd idiosyncrasies on users, such as:
Generated docs require manual editing, which can arguably be worse than no docs because it creates more work for the programmer (the docs are also spelled weirdly)The assist no longer generates docs- We always add
#[must_use]
, which is "weird" – it makes Rust even more boilerplate-heavy and adds visual noise. - We never add
#[inline]
but users might want that, at least when the type in question has no generic type/const parameters.
This leads to people (me) not using the assist because their handwritten code would differ too much from what the assist generates.
We should add a config section for this group of assists and make each of these points configurable. The defaults should possibly be changed as well.