orm 0.2.0

A ORM framework written in Rust, unfinished yet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::mem;
use meta::OrmMeta;
use rustc_serialize::json;

pub unsafe fn init_meta(json: &'static str) -> &'static OrmMeta {
    let meta: OrmMeta = json::decode(json).unwrap();
    leak(meta)
}

pub fn leak<T>(v: T) -> &'static T {
    unsafe {
        let b = Box::new(v);
        let p: *const T = &*b;
        mem::forget(b); // leak our reference, so that `b` is never freed
        &*p
    }
}