Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gothack/rs-async-debug
https://github.com/gothack/rs-async-debug
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/gothack/rs-async-debug
- Owner: GothAck
- Created: 2022-02-22T18:13:40.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-02-23T02:03:24.000Z (over 2 years ago)
- Last Synced: 2024-08-09T16:35:19.662Z (3 months ago)
- Language: Rust
- Size: 110 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Crates.io](https://img.shields.io/crates/v/async-debug)](https://crates.io/crates/async-debug)
[![Crates.io](https://img.shields.io/crates/l/async-debug)](https://crates.io/crates/async-debug)
[![docs.rs](https://img.shields.io/docsrs/async-debug)](https://docs.rs/async-debug)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)# 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
}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.3"
``````rust
use async_debug::AsyncDebug;
use tokio::sync::RwLock;#[derive(AsyncDebug)]
struct MyStruct {
#[async_debug(async_call = RwLock::read, clone, ty = String)]
my_value: RwLock
}let my_struct = MyStruct { my_value: RwLock::from("Hello, world!".to_string()) };
assert_eq!(
format!("{:?}", my_struct.async_debug().await),
"MyStruct { my_value: \"Hello, world!\" }",
);
```