From e1d7be8e576884f78f86a341d52744ddf4b89acb Mon Sep 17 00:00:00 2001 From: Jadon Jesse Date: Tue, 5 Aug 2025 18:45:49 +0200 Subject: [PATCH] fix(example): runtime crash when counter less than 0 (#13955) --- examples/state/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/state/main.rs b/examples/state/main.rs index a8d8c60da..64b4780fe 100644 --- a/examples/state/main.rs +++ b/examples/state/main.rs @@ -8,31 +8,31 @@ use std::sync::Mutex; use tauri::State; -struct Counter(Mutex); +struct Counter(Mutex); #[tauri::command] -fn increment(counter: State<'_, Counter>) -> usize { +fn increment(counter: State<'_, Counter>) -> isize { let mut c = counter.0.lock().unwrap(); *c += 1; *c } #[tauri::command] -fn decrement(counter: State<'_, Counter>) -> usize { +fn decrement(counter: State<'_, Counter>) -> isize { let mut c = counter.0.lock().unwrap(); *c -= 1; *c } #[tauri::command] -fn reset(counter: State<'_, Counter>) -> usize { +fn reset(counter: State<'_, Counter>) -> isize { let mut c = counter.0.lock().unwrap(); *c = 0; *c } #[tauri::command] -fn get(counter: State<'_, Counter>) -> usize { +fn get(counter: State<'_, Counter>) -> isize { *counter.0.lock().unwrap() }