derive_more_impl/as/
ref.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Implementation of an [`AsRef`] derive macro.

use proc_macro2::TokenStream;
use quote::format_ident;

/// Expands an [`AsRef`] derive macro.
pub(crate) fn expand(
    input: &syn::DeriveInput,
    trait_name: &'static str,
) -> syn::Result<TokenStream> {
    let trait_ident = format_ident!("{trait_name}");
    let method_ident = format_ident!("as_ref");

    super::expand(input, (&trait_ident, &method_ident, None))
}