CrystalBuilder

Struct CrystalBuilder 

Source
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 CrystalBuilder<LatticeNotSet, AtomsNotSet>

Source

pub fn new() -> Self

Source§

impl<A> CrystalBuilder<LatticeNotSet, A>

Source

pub fn with_lattice(self, lattice: Lattice) -> CrystalBuilder<LatticeSet, A>

Source§

impl<L> CrystalBuilder<L, AtomsNotSet>

Source

pub fn with_atoms(self, atoms: &[Atom]) -> CrystalBuilder<L, AtomsSet>

Source§

impl CrystalBuilder<LatticeSet, AtomsSet>

Source

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>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CrystalBuilder<LatticeNotSet, AtomsNotSet>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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>
where LatticeState: Send, AtomsState: Send,

§

impl<LatticeState, AtomsState> Sync for CrystalBuilder<LatticeState, AtomsState>
where LatticeState: Sync, AtomsState: Sync,

§

impl<LatticeState, AtomsState> Unpin for CrystalBuilder<LatticeState, AtomsState>
where LatticeState: Unpin, AtomsState: Unpin,

§

impl<LatticeState, AtomsState> UnwindSafe for CrystalBuilder<LatticeState, AtomsState>
where LatticeState: UnwindSafe, AtomsState: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.