bucket

Crates.iobucket
lib.rsbucket
version1.0.0
sourcesrc
created_at2022-03-02 12:55:57.732103
updated_at2022-03-02 12:55:57.732103
descriptionOffers a very simple container for any value without mutation.
homepage
repositoryhttps://github.com/DmitrijVC/bucket
max_upload_size
id542239
size8,209
FssAy (FssAy)

documentation

README

Bucket

Library made for fun that offers a very simple container for any value without mutation.

Beware, it bites.

Example

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]);
}
Commit count: 1

cargo fmt