Skip to content

Commit

Permalink
fix(generational-box): polished README.md (#2168)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew15-5 authored Mar 28, 2024
1 parent d9f78ab commit fd21c97
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/generational-box/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Generational Box

Generational Box is a runtime for Rust that allows any static type to implement `Copy`. It can be combined with a global runtime to create an ergonomic state solution like `dioxus-signals`. This crate contains no `unsafe` code.
Generational Box is a runtime for Rust that allows any static type to implement `Copy`. It can be combined with a global runtime to create an ergonomic state solution like `dioxus-signals`. This crate doesn't have any `unsafe` code.

Three main types manage state in Generational Box:

- Store: Handles recycling generational boxes that have been dropped. Your application should have one store or one store per thread.
- Owner: Handles dropping generational boxes. The owner acts like a runtime lifetime guard. Any states that you create with an owner will be dropped when that owner is dropped.
- GenerationalBox: The core Copy state type. The generational box will be dropped when the owner is dropped.
- `Store`: Handles recycling generational boxes that have been dropped. Your application should have one store or one store per thread.
- `Owner`: Handles dropping generational boxes. The owner acts like a runtime lifetime guard. Any states that you create with an owner will be dropped when that owner is dropped.
- `GenerationalBox`: The core Copy state type. The generational box will be dropped when the owner is dropped.

Example:

Expand All @@ -27,4 +27,4 @@ assert_eq!(*value, "hello world");

## How it works

Internally, `generational-box` creates an arena of generational `RefCell`'s that are recycled when the owner is dropped. You can think of the cells as something like `&'static RefCell<Box<dyn Any>>` with a generational check to make recycling a cell easier to debug. Then GenerationalBox's are `Copy` because the `&'static` pointer is `Copy`
Internally, `generational-box` creates an arena of generational `RefCell`s that are recycled when the owner is dropped. You can think of the cells as something like `&'static RefCell<Box<dyn Any>>` with a generational check to make recycling a cell easier to debug. Then `GenerationalBox`es are `Copy` because the `&'static` pointer is `Copy`.

0 comments on commit fd21c97

Please sign in to comment.