}
let vis = strukt.visibility().map_or(String::new(), |v| format!("{} ", v));
- let (ty, body) = if mutable {
- (format!("&mut {}", field_ty), format!("&mut self.{}", field_name))
+ let (ty, body, description) = if mutable {
+ (
+ format!("&mut {}", field_ty),
+ format!("&mut self.{}", field_name),
+ "a mutable reference to ",
+ )
} else {
let famous_defs = &FamousDefs(&ctx.sema, ctx.sema.scope(field_ty.syntax()).krate());
ctx.sema
(
conversion.convert_type(ctx.db()),
conversion.getter(field_name.to_string()),
+ if conversion.is_copy() { "" } else { "a reference to " },
+ )
+ })
+ .unwrap_or_else(|| {
+ (
+ format!("&{}", field_ty),
+ format!("&self.{}", field_name),
+ "a reference to ",
)
})
- .unwrap_or_else(|| (format!("&{}", field_ty), format!("&self.{}", field_name)))
};
format_to!(
buf,
- " /// Get a {}reference to the {}'s {}.
+ " /// Get {}the {}'s {}.
{}fn {}(&{}self) -> {} {{
{}
}}",
- mutable.then(|| "mutable ").unwrap_or_default(),
+ description,
to_lower_snake_case(&strukt_name.to_string()).replace('_', " "),
fn_name.trim_end_matches("_mut").replace('_', " "),
vis,
struct S { foo: bool }
impl S {
- /// Get a reference to the s's foo.
+ /// Get the s's foo.
fn $0foo(&self) -> bool {
self.foo
}