Browse Source

chore: remove unnecessary anonymous lifetimes (#1829)

Ngo Iok Ui (Wu Yu Wei) 4 years ago
parent
commit
c1f8e11342

+ 0 - 0
.changes/anonymous-lifetime.md → .changes/anonymous-lifetimes.md


+ 1 - 1
core/tauri/src/app.rs

@@ -341,7 +341,7 @@ where
   /// struct MyString(String);
   ///
   /// #[tauri::command]
-  /// fn int_command(state: State<'_, MyInt>) -> String {
+  /// fn int_command(state: State<MyInt>) -> String {
   ///     format!("The stateful int is: {}", state.0)
   /// }
   ///

+ 1 - 1
examples/commands/src-tauri/src/commands.rs

@@ -22,6 +22,6 @@ pub fn simple_command(argument: String) {
 }
 
 #[command]
-pub fn stateful_command(argument: Option<String>, state: State<'_, super::MyState>) {
+pub fn stateful_command(argument: Option<String>, state: State<super::MyState>) {
   println!("{:?} {:?}", argument, state.inner());
 }

+ 2 - 2
examples/splashscreen/src-tauri/src/main.rs

@@ -54,8 +54,8 @@ mod ui {
   #[tauri::command]
   fn close_splashscreen<P: Params>(
     _: Window<P>, // force inference of P
-    splashscreen: State<'_, SplashscreenWindow<P>>,
-    main: State<'_, MainWindow<P>>,
+    splashscreen: State<SplashscreenWindow<P>>,
+    main: State<MainWindow<P>>,
   ) {
     // Close splashscreen
     splashscreen.0.lock().unwrap().close().unwrap();

+ 3 - 3
examples/state/src-tauri/src/main.rs

@@ -23,17 +23,17 @@ struct Counter(AtomicUsize);
 struct Database(Arc<Mutex<HashMap<String, String>>>);
 
 #[tauri::command]
-fn increment_counter(counter: State<'_, Counter>) -> usize {
+fn increment_counter(counter: State<Counter>) -> usize {
   counter.0.fetch_add(1, Ordering::Relaxed) + 1
 }
 
 #[tauri::command]
-fn db_insert(key: String, value: String, db: State<'_, Database>) {
+fn db_insert(key: String, value: String, db: State<Database>) {
   db.0.lock().unwrap().insert(key, value);
 }
 
 #[tauri::command]
-fn db_read(key: String, db: State<'_, Database>) -> Option<String> {
+fn db_read(key: String, db: State<Database>) -> Option<String> {
   db.0.lock().unwrap().get(&key).cloned()
 }