From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 6B33F1FF179 for ; Wed, 10 Dec 2025 11:48:20 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BA8FC18473; Wed, 10 Dec 2025 11:49:00 +0100 (CET) From: Dominik Csapak To: yew-devel@lists.proxmox.com Date: Wed, 10 Dec 2025 11:48:49 +0100 Message-ID: <20251210104856.1698157-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251210104856.1698157-1-d.csapak@proxmox.com> References: <20251210104856.1698157-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [builder.rs] Subject: [yew-devel] [PATCH yew-widget-toolkit 2/3] pwt-macros: builder: allow multiple generic types in callback variant X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" if there is a callback type with multiple generic variants, e.g. Foo we currently can't use it since we only expect one type in the macro. Extend the parser to add multiple types for the generic part. So we can now write for example: #[builder_cb(IntoEventCallback, into_event_callback, A, B)] foo: Callback, This way it's compatible with the current way we write it. Signed-off-by: Dominik Csapak --- pwt-macros/src/builder.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/pwt-macros/src/builder.rs b/pwt-macros/src/builder.rs index 89f791e..ee28bbf 100644 --- a/pwt-macros/src/builder.rs +++ b/pwt-macros/src/builder.rs @@ -85,7 +85,7 @@ impl Parse for FieldOptions { struct CallbackOptions { into_trait: syn::Type, into_fn: syn::Ident, - inner_type: syn::Type, + inner_types: Vec, } impl Parse for CallbackOptions { @@ -105,16 +105,27 @@ impl Parse for CallbackOptions { .parse() .map_err(|err| Error::new(err.span(), format!("expected into function: {err}")))?; + let mut inner_types = Vec::new(); + parse_comma(&content).map_err(|err| Error::new(err.span(), "missing inner type"))?; let inner_type: syn::Type = content.parse().map_err(|err| { Error::new(err.span(), format!("expected inner callback type: {err}")) })?; + inner_types.push(inner_type); + + while parse_comma(&content).is_ok() { + let inner_type: syn::Type = content.parse().map_err(|err| { + Error::new(err.span(), format!("expected inner callback type: {err}")) + })?; + inner_types.push(inner_type); + } + Ok(Self { into_trait, into_fn, - inner_type, + inner_types, }) } } @@ -229,9 +240,9 @@ fn derive_builder(builder: DeriveInput) -> Result { let options = syn::parse2::(tokens)?; let into_fn = options.into_fn; let into_trait = options.into_trait; - let inner_type = options.inner_type; + let inner_types = options.inner_types; ( - quote_spanned! { attr_span => impl #into_trait<#inner_type>}, + quote_spanned! { attr_span => impl #into_trait<#(#inner_types),*>}, quote_spanned! { attr_span => #field_ident.#into_fn()}, ) } -- 2.47.3 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel