# x-selfref
This basically a copy/fork of the MIT-licensed [selfref](https://docs.rs/selfref/latest/selfref/) library (by another author), with a few additions made by me.
# Introduction of selfref
An experimental approach to self-referential structs in Rust.
This crate provides an alternative approach to self-referential structs,
where instead of providing you with a macro or framework where you define
a self-referential struct and it handles all of the details for you, we try
to expose the abstractions and building blocks for making self-referential
structs work well in safe Rust.
For example, a [`Holder`] is a safe wrapper around a self-referential
struct, providing safe APIs for constructing and manipulating a
self-referential struct. However, and unlike other self-referential crates,
it does not dictate the backing storage of the struct. The [`Opaque`] trait
is used to identify a self-referential struct for use with a [`Holder`] -
since Rust does not support higher kinded types (HKTs), this crate uses
generic associated types (GATs) as a workaround.
To use the crate, first define a self-referential struct in plain Rust:
```rust
use std::cell::Cell;
// Your self-referential struct.
struct MySelfRefStruct<'this> {
// Rust uses RAII-like struct construction, as a result this must be
// somehow initialized after the struct. We can use an Option in a Cell
// for this.
this: Cell