1use proc_macro::TokenStream;
2use quote::quote;
3use syn::{parse_macro_input, DeriveInput};
4
5pub fn derive_into_element(input: TokenStream) -> TokenStream {
6 let ast = parse_macro_input!(input as DeriveInput);
7 let type_name = &ast.ident;
8 let (impl_generics, type_generics, where_clause) = ast.generics.split_for_impl();
9
10 let gen = quote! {
11 impl #impl_generics gpui::IntoElement for #type_name #type_generics
12 #where_clause
13 {
14 type Element = gpui::Component<Self>;
15
16 fn element_id(&self) -> Option<gpui::ElementId> {
17 None
18 }
19
20 fn into_element(self) -> Self::Element {
21 gpui::Component::new(self)
22 }
23 }
24 };
25
26 gen.into()
27}