Docs.rs
  • async-debug-0.1.1
    • async-debug 0.1.1
    • Docs.rs crate page
    • MIT
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • GothAck
    • Dependencies
      • async-debug-derive ^0.1.1 normal
      • tokio ~1.17.0 dev
      • trybuild ~1.0.56 dev
      • version-sync ~0.9.4 dev
    • Versions
    • 50% of the crate is documented
  • Go to latest version
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Badges
    • Builds
    • Metadata
    • Shorthand URLs
    • Download
    • Rustdoc JSON
    • Build queue
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation
logo

Crate async_debug

logo

Crate async_debug

  • Version 0.1.1
  • All Items
  • Traits
  • Derive Macros

Traits

  • AsyncDebug
logo
Change settings

Crate async_debug

source · [−]
Expand description

Async Debug

The async-debug crate makes it easy to debug structs and enums containing values that require an async call to render.

For example:

use tokio::sync::RwLock;

#[derive(Debug)]
struct MyStruct {
    my_value: RwLock<String>
}

let my_struct = MyStruct { my_value: RwLock::from("Hello, world!".to_string()) };
println!("{:?}", my_struct );

Prints something like:

MyStruct { my_value: RwLock { mr: 536870911, s: Semaphore { permits: 536870911 }, c: UnsafeCell { .. } } }

Along comes Async Debug

Just derive from async_debug::AsyncDebug and add the appropriate attribute!

Add to cargo.toml:

[dependencies]
async-debug = "0.1.1"
use async_debug::AsyncDebug;
use tokio::sync::RwLock;

#[derive(AsyncDebug)]
struct MyStruct {
    #[async_debug(parse = RwLock::read, clone, ty = String)]
    my_value: RwLock<String>
}

let my_struct = MyStruct { my_value: RwLock::from("Hello, world!".to_string()) };
assert_eq!(
    format!("{:?}", my_struct.async_debug().await),
    "MyStructAsyncDebug { my_value: \"Hello, world!\" }",
);

Traits

AsyncDebug

Derive Macros

AsyncDebug

Loading search results...