Allow the main ruma crate to re-export the ruma-api-macro things

This commit is contained in:
Devin Ragotzy 2020-08-10 17:07:03 -04:00 committed by Jonas Platte
parent 6877c2f38d
commit 98ddf25ae2

View File

@ -28,9 +28,12 @@ pub fn strip_serde_attrs(field: &Field) -> Field {
} }
pub fn import_ruma_api() -> TokenStream { pub fn import_ruma_api() -> TokenStream {
if let Ok(name) = crate_name("ruma-api") { if let Ok(possibly_renamed) = crate_name("ruma-api") {
let import = Ident::new(&name, Span::call_site()); let import = Ident::new(&possibly_renamed, Span::call_site());
quote! { ::#import } quote! { ::#import }
} else if let Ok(possibly_renamed) = crate_name("ruma") {
let import = Ident::new(&possibly_renamed, Span::call_site());
quote! { ::#import::api }
} else { } else {
quote! { ::ruma_api } quote! { ::ruma_api }
} }