#extend #container #no-std #traits #finite #iterator #items

no-std fill

Provides the Fill trait, an alternative to Extend for finite containers

2 releases

0.1.1 Jan 26, 2020
0.1.0 Jan 19, 2020

#1154 in Embedded development

24 downloads per month

MIT license

13KB
140 lines

fill

Crates.io Status Docs.rs Status License CI Status

Provides the Fill trait, an alternative to Extend for finite containers.

Usage

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));

No runtime deps

Features