Crates.io | valet |
lib.rs | valet |
version | 0.1.1 |
source | src |
created_at | 2022-04-17 05:04:38.381082 |
updated_at | 2022-04-17 05:05:35.890195 |
description | Stores your objects and gives you a tag to retrieve them later. |
homepage | |
repository | https://github.com/agausmann/valet |
max_upload_size | |
id | 569300 |
size | 5,712 |
Stores your objects, and gives you a tag to retrieve them later.
This is my own solution to the problem of self-referential data. A common
pattern is to eliminate cycles by storing all items in a central collection, and
where you would usually store references or smart pointers, you instead store an
index/key into the collection. In this case, the Valet
type is the collection,
and the Tag
type is the index.
I found that I was often wanting to use this pattern in different projects, and
so instead of writing the same boilerplate to generate indexes I decided to turn
it into a library. That also gave me an excuse to add other nice-to-have
features, like better type safety for indexes, using a generic newtype Tag<T>
instead of a plain type like u64
.