pub struct CrystalBuilder<LatticeState, AtomsState> { /* private fields */ }Expand description
use builder pattern so the validation is runtime
To make it a compile time check, I can use the proc macro (build/build_unchcek API).
§Example
use ccmat::*;
let lattice = lattice_angstrom![
a = (1.0, 0.0, 0.0),
b = (0.0, 1.0, 0.0),
c = (0.0, 0.0, 1.0),
];
let atoms = vec![];
let crystal = CrystalBuilder::new()
.with_lattice(lattice)
.with_atoms(&atoms)
.build()
.unwrap();Implementations§
Source§impl<A> CrystalBuilder<LatticeNotSet, A>
impl<A> CrystalBuilder<LatticeNotSet, A>
pub fn with_lattice(self, lattice: Lattice) -> CrystalBuilder<LatticeSet, A>
Source§impl<L> CrystalBuilder<L, AtomsNotSet>
impl<L> CrystalBuilder<L, AtomsNotSet>
pub fn with_atoms(self, atoms: &[Atom]) -> CrystalBuilder<L, AtomsSet>
Source§impl CrystalBuilder<LatticeSet, AtomsSet>
impl CrystalBuilder<LatticeSet, AtomsSet>
Sourcepub fn build(self) -> Result<Crystal, CrystalValidateError>
pub fn build(self) -> Result<Crystal, CrystalValidateError>
build and validate the it is a valid crystal. At the moment only validate the size(positions) == size(numbers)
Trait Implementations§
Source§impl<LatticeState: Debug, AtomsState: Debug> Debug for CrystalBuilder<LatticeState, AtomsState>
impl<LatticeState: Debug, AtomsState: Debug> Debug for CrystalBuilder<LatticeState, AtomsState>
Source§impl Default for CrystalBuilder<LatticeNotSet, AtomsNotSet>
impl Default for CrystalBuilder<LatticeNotSet, AtomsNotSet>
Auto Trait Implementations§
impl<LatticeState, AtomsState> Freeze for CrystalBuilder<LatticeState, AtomsState>
impl<LatticeState, AtomsState> RefUnwindSafe for CrystalBuilder<LatticeState, AtomsState>where
LatticeState: RefUnwindSafe,
AtomsState: RefUnwindSafe,
impl<LatticeState, AtomsState> Send for CrystalBuilder<LatticeState, AtomsState>
impl<LatticeState, AtomsState> Sync for CrystalBuilder<LatticeState, AtomsState>
impl<LatticeState, AtomsState> Unpin for CrystalBuilder<LatticeState, AtomsState>
impl<LatticeState, AtomsState> UnwindSafe for CrystalBuilder<LatticeState, AtomsState>where
LatticeState: UnwindSafe,
AtomsState: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more