context_manager 0.1.3

Python's like context_managers in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use context_manager::SyncWrapContext;
use context_manager_macro::wrap;

struct Sync;
impl<T> SyncWrapContext<T> for Sync {
    fn new() -> Self {
        Self
    }
}

#[wrap(Sync)]
const fn sync_foo<'a, T: ?Sized>(v: &'a T) -> &'a T {
    v
}

fn main() {
    assert_eq!(sync_foo("10"), "10");
}