Эх сурвалжийг харах

impl Debug for State closes #3676 (#3677)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Jonas Kruckenberg 3 жил өмнө
parent
commit
0b49dd566d

+ 5 - 0
.changes/state-debug.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Implement `Debug` for `tauri::State`.

+ 6 - 0
core/tauri/src/state.rs

@@ -37,6 +37,12 @@ impl<T: Send + Sync + 'static> Clone for State<'_, T> {
   }
 }
 
+impl<'r, T: Send + Sync + std::fmt::Debug> std::fmt::Debug for State<'r, T> {
+  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+    f.debug_tuple("State").field(&self.0).finish()
+  }
+}
+
 impl<'r, 'de: 'r, T: Send + Sync + 'static, R: Runtime> CommandArg<'de, R> for State<'r, T> {
   /// Grabs the [`State`] from the [`CommandItem`]. This will never fail.
   fn from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError> {