1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! # 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:
//! ```rust
//! use tokio::sync::RwLock;
//!
//! #[derive(Debug)]
//! struct MyStruct {
//!     my_value: RwLock<String>
//! }
//!
//! # fn main() {
//! let my_struct = MyStruct { my_value: RwLock::from("Hello, world!".to_string()) };
//! println!("{:?}", my_struct );
//! # }
//! ```
//!
//! Prints something like:
//! ```text
//! 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:
//! ```toml
//! [dependencies]
//! async-debug = "0.1.0"
//! ```
//!
//! ```rust
//! use async_debug::AsyncDebug;
//! use tokio::sync::RwLock;
//!
//! #[derive(AsyncDebug)]
//! struct MyStruct {
//!     #[async_debug(parse = RwLock::read, clone, ty = String)]
//!     my_value: RwLock<String>
//! }
//!
//! # #[tokio::main]
//! # async fn main() {
//! 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!\" }",
//! );
//! # }
pub use async_debug_derive::AsyncDebug;

pub trait AsyncDebug {}