Crates.io | deferred_vector |
lib.rs | deferred_vector |
version | 0.1.2 |
source | src |
created_at | 2023-11-29 02:12:43.301345 |
updated_at | 2023-11-29 02:26:41.491012 |
description | A deferred vector implementation |
homepage | |
repository | https://github.com/afmiguel/deferred_vector |
max_upload_size | |
id | 1052535 |
size | 9,201 |
The Deferred Vector Library offers DeferredVec
, a generic, lazily-initialized vector structure in Rust, ideal for efficient resource management and performance optimization. Developed by Prof. Afonso Miguel at PUCPR.
T
that implements the Clone
trait.Instantiate DeferredVec
with a fetch_function
defining the initial state. The vector remains uninitialized (None
) until methods like get
or len
are invoked, triggering initialization.
Basic usage:
let mut deferred_vector = DeferredVec::new(|| vec![1, 2, 3]);
assert_eq!(deferred_vector.is_deferred(), true);
Fetch de vector data:
assert_eq!(deferred_vector.len(), 3);
Check if the vector is not deferred:
let initialized_vector = deferred_vector.get();
assert_eq!(deferred_vector.is_deferred(), false);
Includes unit tests focusing on lazy initialization and basic vector operations.
Provided as-is, without warranty. Test thoroughly before production use.
Prof. Afonso Miguel - PUCPR.
MIT License - see the LICENSE file for details.