• Crate im — Immutable Data Structures for Rust
    https://clojurust.github.io/clojurust.doc/im

    #clojure #rust #immutable #dataStructures #amazing #bodil

    « This library implements several of the more commonly useful immutable data structures for Rust.

    What are immutable data structures?

    Immutable data structures are data structures which can be copied and modified efficiently without altering the original. The most uncomplicated example of this is the venerable cons list. This crate offers a selection of more modern and flexible data structures with similar properties, tuned for the needs of Rust developers.

    Briefly, the following data structures are provided:

    Vectors based on RRB trees;
    Hash maps/sets based on hash array mapped tries;
    * Ordered maps/sets based on B-trees.

    Why Would I Want This?

    While immutable data structures can be a game changer for other programming languages, the most obvious benefit - avoiding the accidental mutation of data - is already handled so well by Rust’s type system that it’s just not something a Rust programmer needs to worry about even when using data structures that would send a conscientious Clojure programmer into a panic.

    Immutable data structures offer other benefits, though, some of which are useful even in a language like Rust. The most prominent is structural sharing, which means that if two data structures are mostly copies of each other, most of the memory they take up will be shared between them. […] »