Crates.io | fill |
lib.rs | fill |
version | 0.1.1 |
source | src |
created_at | 2020-01-19 16:39:05.035957 |
updated_at | 2020-01-26 20:33:09.914356 |
description | Provides the Fill trait, an alternative to Extend for finite containers |
homepage | |
repository | https://github.com/HeroicKatora/static-alloc |
max_upload_size | |
id | 200175 |
size | 14,529 |
Provides the Fill trait, an alternative to Extend for finite containers.
The official recommendation for the Extend
trait is to simulate pushing all
items from the iterator, panicking if a resource limit is exceeded. Instead of
looping over all items the implementors of Fill
should only pull items from
the iterator while space is available. For example, an option can be viewed as
a collection with a capacity of one. One can fill it with the first item of an
iterator if it is empty.
use fill::Fill;
let mut memory = None;
memory.fill(42..);
assert_eq!(memory, Some(42));