From 2a34be5815787a536974e30df02605e9ac1e19d9 Mon Sep 17 00:00:00 2001 From: Andrew Barnes Date: Tue, 10 Mar 2026 14:33:41 -0400 Subject: [PATCH] =?UTF-8?q?Fix=20panic=20in=20calculator=20when=20pressing?= =?UTF-8?q?=20=C2=B1=20after=20AC=20(#5352)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: handle empty string in calculator plus-minus button calc_val() panics on empty string when AC is pressed before the plus-minus button. Return 0.0 early for empty input. Fixes #4858 * fix a few ci failures * fix link check --------- Co-authored-by: Evan Almloff --- examples/01-app-demos/calculator.rs | 4 ++++ notes/translations/pt-br/README.md | 6 +++--- packages/rsx/src/partial_closure.rs | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/01-app-demos/calculator.rs b/examples/01-app-demos/calculator.rs index 83c469f8c..143ef653a 100644 --- a/examples/01-app-demos/calculator.rs +++ b/examples/01-app-demos/calculator.rs @@ -148,6 +148,10 @@ fn app() -> Element { } fn calc_val(val: &str) -> f64 { + if val.is_empty() { + return 0.0; + } + let mut temp = String::new(); let mut operation = "+".to_string(); diff --git a/notes/translations/pt-br/README.md b/notes/translations/pt-br/README.md index a72bd6b79..7d353e411 100644 --- a/notes/translations/pt-br/README.md +++ b/notes/translations/pt-br/README.md @@ -83,9 +83,9 @@ Se você conhece React, então você já conhece o Dioxus. ## Projetos de Exemplo: -| Navegador de Arquivos (Desktop) | WiFi Scanner (Desktop) | TodoMVC (Todas as Plataformas) | E-commerce com Tailwind (SSR/LiveView) | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [![Explorador de Arquivos](https://github.com/DioxusLabs/example-projects/blob/master/file-explorer/assets/image.png)](https://github.com/DioxusLabs/example-projects/blob/master/file-explorer) | [![Wifi Scanner Demo](/examples/bluetooth-scanner/demo_small.png)](/examples/bluetooth-scanner/) | [![TodoMVC example](https://github.com/DioxusLabs/example-projects/raw/master/todomvc/example.png)](https://github.com/DioxusLabs/example-projects/blob/master/todomvc) | [![Exemplo de E-commerce](https://github.com/DioxusLabs/example-projects/raw/master/ecommerce-site/demo.png)](https://github.com/DioxusLabs/example-projects/blob/master/ecommerce-site) | +| Navegador de Arquivos (Desktop) | WiFi Scanner (Desktop) | TodoMVC (Todas as Plataformas) | E-commerce com Tailwind (SSR/LiveView) | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [![Explorador de Arquivos](https://github.com/DioxusLabs/example-projects/blob/master/file-explorer/assets/image.png)](https://github.com/DioxusLabs/example-projects/blob/master/file-explorer) | [![Wifi Scanner Demo](../../../examples/01-app-demos/bluetooth-scanner/demo_small.png)](../../../examples/01-app-demos/bluetooth-scanner/) | [![TodoMVC example](https://github.com/DioxusLabs/example-projects/raw/master/todomvc/example.png)](https://github.com/DioxusLabs/example-projects/blob/master/todomvc) | [![Exemplo de E-commerce](https://github.com/DioxusLabs/example-projects/raw/master/ecommerce-site/demo.png)](https://github.com/DioxusLabs/example-projects/blob/master/ecommerce-site) | Veja a página [awesome-dioxus](https://github.com/DioxusLabs/awesome-dioxus) para uma lista curada do conteúdo dentro do ecossistema do Dioxus. diff --git a/packages/rsx/src/partial_closure.rs b/packages/rsx/src/partial_closure.rs index 560922898..f48ece12a 100644 --- a/packages/rsx/src/partial_closure.rs +++ b/packages/rsx/src/partial_closure.rs @@ -11,7 +11,7 @@ use syn::{BoundLifetimes, ExprClosure}; /// A closure whose body might not be valid rust code but we want to interpret it regardless. /// This lets us provide expansions in way more cases than normal closures at the expense of an -/// increased mainteance burden and complexity. +/// increased maintenance burden and complexity. /// /// We do our best to reuse the same logic from partial exprs for the body of the PartialClosure. /// The code here is simply stolen from `syn::ExprClosure` and lightly modified to work with