Expand description

Convert a Graph into its Rust code equivalent.

This allows one to generate a Graph at build time and then insert it into the binary. This allows large graphs to be used in embedded systems with next to no cost.

Example

use intern_str::{Graph, Segmentable};
use intern_str::builder::{Builder, Utf8Graph};
use intern_str_codegen::generate;
use std::{fs::File, io::{prelude::*, BufWriter}};

let mut builder = Builder::<_, Utf8Graph>::new();

builder.add("hello", 1).unwrap();
builder.add("world", 2).unwrap();

let mut buffer = Vec::new();
let graph = builder.build(&mut buffer);

// Convert to string.
let code = generate(
    &graph,
    "&'static str",
    "usize",
    |f, out| write!(f, "{}", out),
);

let mut out = BufWriter::new(File::create("graph.rs").unwrap());
writeln!(
    out,
    "const GRAPH: intern_str::Graph<'static, 'static, &'static str, usize> = {}",
    code,
)?;

Traits

An item that can be used as a key.

Functions

The whole point.