| Crates.io | mofurun |
| lib.rs | mofurun |
| version | 0.4.0 |
| created_at | 2020-05-28 07:45:00.354585+00 |
| updated_at | 2020-09-17 00:46:53.810976+00 |
| description | Multi 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 | |
| repository | https://github.com/hbina/mofurun |
| max_upload_size | |
| id | 246956 |
| size | 15,649 |
🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸
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.
🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸🧸
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.