Explorar o código

impl Debug for State closes #3676 (#3677)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Jonas Kruckenberg %!s(int64=3) %!d(string=hai) anos
pai
achega
0b49dd566d
Modificáronse 2 ficheiros con 11 adicións e 0 borrados
  1. 5 0
      .changes/state-debug.md
  2. 6 0
      core/tauri/src/state.rs

+ 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> {