Created
August 5, 2014 04:32
-
-
Save tbillington/8ba16432b005b93c6a08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::File; | |
use std::io::BufferedReader; | |
use std::rc::Rc; | |
use std::cell::RefCell; | |
use std::cell::Cell; | |
struct Vertex { | |
x: f64, | |
y: f64, | |
z: f64, | |
} | |
struct Face { | |
a: Rc<Cell<Vertex>>, | |
b: Rc<Cell<Vertex>>, | |
c: Rc<Cell<Vertex>>, | |
d: Rc<Cell<Vertex>>, | |
} | |
fn parse_line(line: &str) { | |
let first_character = line.chars().next(); | |
match first_character { | |
Some('#') => println!("Comment"), | |
Some('v') => println!("Vertex"), | |
Some('s') => println!("Shading"), | |
Some('f') => println!("Face"), | |
Some(x) => println!("Unknown {}" , x), | |
None => () | |
} | |
} | |
fn main() { | |
let v = Rc::new(Cell::new( | |
Vertex { | |
x:1.5, | |
y:1.5, | |
z:1.5})); | |
let x = Face { | |
a:v.clone(), | |
b:v.clone(), | |
c:v.clone(), | |
d:v.clone()}; | |
println!("{}",x.a.get().x); | |
x.a.set( | |
Vertex{x:3.0,y:3.0,z:3.0}); | |
// Is there a way to set a field of the Vertex instead of setting a new Vertex? | |
println!("{}",x.a.get().x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment