Registry / utility / self-cell

self-cell

JSON →
library1.2.2rscratesunverified

Safe-to-use proc-macro-free self-referential structs in stable Rust.

# Cargo.toml [dependencies] self_cell = "1.2.2"
INSTALL
IMPORT
SIG · SELF-CELL
S
self-cell
utilityrustv1.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

self_cell
✓ use self_cell::self_cell;

Create a self-referential struct using the self_cell macro.

use self_cell::self_cell; self_cell!( struct MyCell { owner: String, #[not_covariant] dependent: &str, } ); fn main() { let cell = MyCell::new("hello".to_string(), |s| &s[..]); println!("{}", cell.borrow_dependent()); }
Debug
Known issues
gotchaThe dependent field must be marked with #[not_covariant] to avoid unsoundness.
fix
Add #[not_covariant] attribute to the dependent field.
affects: >=1.0.0
Upgrade
Version history
1.2.2latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
self-cell — cargo add self-cell · libregistry