1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use proc_macro2::TokenStream as TokenStream2;
use quote::{quote, quote_spanned};
use syn::{spanned::Spanned, token};
use super::{PropertyName, ReturnedWidget, Widget, WidgetTemplateAttr};
mod util;
mod struct_fields;
mod return_fields;
mod assign;
mod conditional_init;
mod destructure_fields;
mod error;
mod init;
mod update_view;
impl Widget {
pub(super) fn widget_assignment(&self) -> TokenStream2 {
let w_name = &self.name;
let ref_token = &self.ref_token;
let deref_token = &self.deref_token;
let template_deref =
(self.template_attr == WidgetTemplateAttr::Template).then(token::Star::default);
let out_stream = quote! { #ref_token #deref_token #template_deref #w_name };
if let Some(wrapper) = &self.assign_wrapper {
quote_spanned! {
wrapper.span() => #wrapper(#out_stream)
}
} else {
out_stream
}
}
}