Skip to content

Instantly share code, notes, and snippets.

@fkaa
Created April 19, 2014 01:31
Show Gist options
  • Select an option

  • Save fkaa/11070927 to your computer and use it in GitHub Desktop.

Select an option

Save fkaa/11070927 to your computer and use it in GitHub Desktop.
struct Asset {
cache: HashMap<~str, Gc<~Any>>
}
impl Asset {
pub fn load<T>(path: Path) -> IoResult<@T> {
let fc = FileContent::from(path); //temp
let ret = fc.unwrap();
Ok(unsafe { cast::transmute(@ret) })
}
}
fn main() {
/*let foo: @int = Asset::load::<int>(Path::new("foo.txt")).unwrap();
println!("{}", foo);*/
let fc: @FileContent = Asset::load::<FileContent>(Path::new("foo.txt")).unwrap();
fc.foo();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment