Crates.io | bucket |
lib.rs | bucket |
version | 1.0.0 |
source | src |
created_at | 2022-03-02 12:55:57.732103 |
updated_at | 2022-03-02 12:55:57.732103 |
description | Offers a very simple container for any value without mutation. |
homepage | |
repository | https://github.com/DmitrijVC/bucket |
max_upload_size | |
id | 542239 |
size | 8,209 |
Library made for fun that offers a very simple container for any value without mutation.
Beware, it bites.
See src/tests.rs
for more examples.
use bucket::Bucket;
fn main() {
let my_val: Vec<u32> = vec![1, 2, 3];
// Creates new Bucket and takes the ownership of `my_val`.
let bucket = Bucket::new(my_val);
// Increases every number from the vector by 1.
// Mutation of the Bucket isn't needed.
for number in bucket.peek_mut().unwrap() {
*number += 1;
}
// Returns content of the Bucket.
let _ = bucket.vacate().unwrap();
// Now the Bucket can be filled with other u32 vector.
bucket.fill(vec![4, 4, 4]);
}