use crate::{Lattice, Scalar};
pub trait HasLattice<V: Scalar> {
fn lattice(&self) -> Lattice<V>;
}
#[cfg(test)]
mod tests {
use super::*;
use crate::units::length::{Angstrom, Length};
use crate::units::volume::CubicAngstrom;
struct Crystal {
lattice: Lattice<f64>,
}
impl HasLattice<f64> for Crystal {
fn lattice(&self) -> Lattice<f64> {
self.lattice
}
}
#[test]
fn lattice() {
let crystal = Crystal {
lattice: Lattice::cubic(Length::<f64, Angstrom>::new(2.0)).unwrap(),
};
assert_eq!(crystal.lattice().volume::<CubicAngstrom>().value(), 8.0);
}
}