Created
September 17, 2015 22:30
-
-
Save ehermes/320de3ca3e1e53fe7ed1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
struct Atom { | |
position: [f32; 3], | |
epsilon: f32, | |
sigma: f32, | |
} | |
impl Atom { | |
fn new(x: f32, y: f32, z: f32, epsilon: f32, sigma: f32) -> Atom { | |
Atom { | |
position: [x, y, z], | |
sigma: sigma, | |
epsilon: epsilon, | |
} | |
} | |
} | |
struct Box { | |
a: f32, | |
b: f32, | |
c: f32, | |
atoms: &mut Vec<Atom>, | |
} | |
impl Box { | |
fn new(a: f32, b: f32, c: f32, atoms: &mut Vec<Atom>) -> Box { | |
Box { | |
a: a, | |
b: b, | |
c: c, | |
atoms: atoms, | |
} | |
} | |
} | |
fn main() { | |
let mut a1 = Atom::new(0., 0., 0., 1., 1.); | |
let mut a2 = Atom::new(5., 5., 5., 1., 1.); | |
let mut atoms = vec![a1, a2]; | |
let b = Box(10., 10., 10., &mut atoms); | |
println!("{}", b.atoms[0].position[0]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment