mofurun

Crates.iomofurun
lib.rsmofurun
version0.4.0
sourcesrc
created_at2020-05-28 07:45:00.354585
updated_at2020-09-17 00:46:53.810976
descriptionMulti variant Optimized Fun U....okay Mofu is just a cute name okay. Experimental implementation of Vec that stores the state of the underlying array through its enum.
homepage
repositoryhttps://github.com/hbina/mofurun
max_upload_size
id246956
size15,649
Hanif Ariffin (hbina)

documentation

README

🧸 Mofurun 🧸

🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸

Experimental implementation of Vec that stores the state of the underlying array using types.

This allows us to optimize some operations based on its state.

🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸

Example

For the simplest case, consider finding the maximum value in a vector.

use mofurun::{sorted_vec::SortedVec, unsorted_vec::UnsortedVec};
pub fn main() {
    // Although we began with a sorted vector, we ended up with an unsorted vector.
    let s : UnsortedVec<i32> = SortedVec::default()
        .push(5)
        .push(4)
        .push(3)
        .push(2)
        .push(1)
        .push(0);
    // Recover sorted vector.
    let s : SortedVec<i32> = s.sort();
}

I think there are many, many more containers like this and I am generally interested in the idea of using structs to force the logic of a program.

Commit count: 0

cargo fmt