packo 0.3.1

Packed datastructure with self referential indexing.
Documentation
use packo::Packo;

pub type Document = Packo<256, Tag, 1, u8>;

pub struct Tag {
    name: &'static str,
    text: &'static str,
}

#[rustfmt::skip]
fn main() {
    let mut doc = Document::default();

    let html = doc.insert(Tag { name: "html", text: "" });
    let body = doc.nest(html, Tag{ name: "body", text: "" });
    let p1 = doc.nest(body, Tag{ name: "p", text: "first line" }); 
    let _p2 = doc.append(p1, Tag{ name: "p", text: "second line" }); 

    print(&doc, html);
    println!();

    println!("{doc}");
}

fn print(d: &Document, i: u8) {
    print!("<{}>", d[i].name);
    let s = d.child(i);
    let mut c = s;
    while c != 0 {
        print(d, c);
        c = d.next(c);
        if c == s {
            break;
        }
    }
    print!("{}", d[i].text);
    print!("</{}>", d[i].name);
}