WeakSelf is simple way to have a Weak pointer inside a data structure pointing to itself.
Sometimes you want to create a struct
with a pointer to itself or just some other recursive data structure.
```rust struct Foo { me: &Foo }
impl Foo { pub fn new() -> Foo { let foo = Foo{ me: ???? }; foo } }
```
This create helps you do that:
```rust
pub struct Foo {
weak_self: WeakSelf
impl Foo {
pub fn new() -> Arc
fn weak(&self) -> Weak<Self> {
self.weak_self.get()
}
}
```
This package depends on std only
To use WeakSelf, add this to your Cargo.toml
:
toml
[dependencies]
weakself = "1.0.0"
Licensed under the terms of MIT license and the Apache License (Version 2.0).
See LICENSE-MIT and LICENSE-APACHE for details.