Open CGMossa opened 1 month ago
Okay, I did indeed find the right place for this. The change would have to be here in some fashion. Here's an attempt:
diff --git a/impl/src/lib.rs b/impl/src/lib.rs
index eeccdb0..0eebc3b 100644
--- a/impl/src/lib.rs
+++ b/impl/src/lib.rs
@@ -97,9 +97,12 @@ impl Output for Result<proc_macro2::TokenStream, ParseError> {
macro_rules! create_derive(
($feature:literal, $mod_:ident $(:: $mod_rest:ident)*, $trait_:ident, $fn_name: ident $(,$attribute:ident)* $(,)?) => {
+ create_derive!($feature, $feature, $mod_ $(:: $mod_rest)*, $trait_, $fn_name $(,$attribute)*);
+ };
+ ($feature:literal, $documentation:literal, $mod_:ident $(:: $mod_rest:ident)*, $trait_:ident, $fn_name: ident $(,$attribute:ident)* $(,)?) => {
#[cfg(feature = $feature)]
#[proc_macro_derive($trait_, attributes($($attribute),*))]
- #[doc = include_str!(concat!("../doc/", $feature, ".md"))]
+ #[doc = include_str!(concat!("../doc/", $documentation, ".md"))]
pub fn $fn_name(input: TokenStream) -> TokenStream {
let ast = syn::parse(input).unwrap();
Output::process($mod_$(:: $mod_rest)*::expand(&ast, stringify!($trait_)))
@@ -134,7 +137,7 @@ create_derive!(
bit_xor_assign_derive,
);
-create_derive!("as_ref", r#as::r#mut, AsMut, as_mut_derive, as_mut);
+create_derive!("as_ref", "as_mut", r#as::r#mut, AsMut, as_mut_derive, as_mut);
create_derive!("as_ref", r#as::r#ref, AsRef, as_ref_derive, as_ref);
create_derive!("constructor", constructor, Constructor, constructor_derive);
Hello @JelteF. Sorry for the ping, I just want to say, that there is this issue too, and it has a suggested solution, although it is not too elegant. What do you think?
Afaict this is another instance of https://github.com/JelteF/derive_more/issues/348, it's a bit special because previously AsMut
and AsRef
had different implementations and thus different documentation. But my preference would be to remove the copy pasted as_mut.md
file from the repo and mention at the top that the derive for AsMut
its very similar to AsRef
.
The issue is seen in https://docs.rs/derive_more/latest/derive_more/derive.AsMut.html#
Here's a screenshot:
Suggestion?
It might be this place:
I'm getting a compile error:
Sorry, I'm either dense or something is slightly wrong.