Skip to content

Instantly share code, notes, and snippets.

@steveklabnik
Forked from TheOpenDevProject/File Load.rs
Last active November 3, 2015 10:54
Show Gist options
  • Save steveklabnik/e6e3a059affde437db4e to your computer and use it in GitHub Desktop.
Save steveklabnik/e6e3a059affde437db4e to your computer and use it in GitHub Desktop.
extern crate gl;
extern crate glutin;
extern crate libc;
use std::io::prelude::*;
use std::io;
use std::fs::File;
fn main(){
let s = read_file("model.obj");
// s is a Result, you need to do something with it
}
fn read_file(s: &str) -> io::Result<String> {
let mut file = try!(File::open(s));
let mut f_content = String::new();
try!(file.read_to_string(&mut f_content));
Ok(f_content);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment