Skip to main content

Crate hirpdag

Crate hirpdag 

Source
Expand description

Hirpdag (Hashconsed Immutable Reduced Property Directed Acyclic Graph) data structures, generated by the #[hirpdag_module] attribute macro (see its documentation for the attribute arguments):

use hirpdag::*;

#[hirpdag_module]
mod datamodel {
    #[hirpdag]
    struct Node {
        name: String,
        children: Vec<Node>,
    }
}
use datamodel::*;

fn main() {
    let leaf = Node::new("leaf".to_string(), vec![]);
    let a = Node::new("parent".to_string(), vec![leaf.clone()]);
    let b = Node::new("parent".to_string(), vec![leaf]);
    // Hash-consing: structurally equal nodes are the same interned node.
    assert_eq!(a, b);
}

The inner attribute form is not accepted by Rust (rust-lang/rust#54726):

use hirpdag::*;

mod datamodel {
    #![hirpdag_module]
}

Re-exports§

pub use hirpdag_hashconsing;
pub use postcard;
pub use serde;
pub use serde_json;

Modules§

base

Macros§

lazy_static