ruwuma/crates/ruma-macros/src/serde/as_str_as_ref_str.rs
Jonas Platte c7e84c5249
Fix clippy lints
Automated using `cargo clippy --fix`.
2022-10-26 13:38:29 +02:00

17 lines
451 B
Rust

use proc_macro2::{Ident, TokenStream};
use quote::quote;
pub fn expand_as_str_as_ref_str(ident: &Ident) -> syn::Result<TokenStream> {
let as_str_doc = format!("Creates a string slice from this `{ident}`.");
Ok(quote! {
#[automatically_derived]
#[allow(deprecated)]
impl #ident {
#[doc = #as_str_doc]
pub fn as_str(&self) -> &str {
self.as_ref()
}
}
})
}