Crates.io | lazy-array |
lib.rs | lazy-array |
version | 0.1.2 |
source | src |
created_at | 2018-04-14 03:19:23.510967 |
updated_at | 2018-04-14 03:43:02.36533 |
description | An array where entries are lazily initialized in any order. |
homepage | https://github.com/animalsiknow/lazy-array |
repository | |
max_upload_size | |
id | 60507 |
size | 38,940 |
LazyArray
is a data structure that contains a fixed number of entries that are indexed by a usize
from 0 up to 1 before its size. All entries start by being undefined, that means that trying to get
them will return None
. Once for each entry, they can be set and once set they can never change.
I had the idea of this library as I was parsing a binary format that contains a sequence of record that may reference each other to form an acyclic graph. The problem is that I can't a priori know in which order to load the objects as any object can reference objects before and after itself. With LazyArray
I can lazily load objects as I discover dependencies between them and store them so they are only loaded once.
LazyArray
is implemented by storing a Vec
inside an UnsafeCell
. I think it is fine for the following reasons.
None
from outside.Sync
.