mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 13:57:16 +00:00
fix(example): runtime crash when counter less than 0 (#13955)
This commit is contained in:
parent
90c1c327ac
commit
e1d7be8e57
@ -8,31 +8,31 @@ use std::sync::Mutex;
|
||||
|
||||
use tauri::State;
|
||||
|
||||
struct Counter(Mutex<usize>);
|
||||
struct Counter(Mutex<isize>);
|
||||
|
||||
#[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()
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user