pub struct Unit<'a> { /* private fields */ }Expand description
Zero-copy view into a subset of a Model.
Unit holds a reference to a Model and an OrderedSet of selected atom indices.
All operations are lazy — iterators do not allocate, and set operations produce
new Units without copying coordinate data.
Implementations§
Source§impl<'a> Unit<'a>
impl<'a> Unit<'a>
Sourcepub fn from_mask(model: &'a Model, mask: &[bool]) -> Self
pub fn from_mask(model: &'a Model, mask: &[bool]) -> Self
Create a Unit from a boolean mask.
The mask must have the same length as model.n_atoms().
Only atoms where mask[i] == true are included.
§Panics
Panics if mask.len() != model.n_atoms().
Sourcepub fn from_indices(model: &'a Model, indices: OrderedSet) -> Self
pub fn from_indices(model: &'a Model, indices: OrderedSet) -> Self
Create a Unit from pre-computed indices.
Sourcepub fn atom_indices(&self) -> impl Iterator<Item = u32> + '_
pub fn atom_indices(&self) -> impl Iterator<Item = u32> + '_
Lazy iterator over selected atom indices.
Sourcepub fn coords(&self) -> impl Iterator<Item = [f32; 3]> + '_
pub fn coords(&self) -> impl Iterator<Item = [f32; 3]> + '_
Lazy iterator over coordinates of selected atoms.
Sourcepub fn union(&self, other: &Unit<'a>) -> Self
pub fn union(&self, other: &Unit<'a>) -> Self
Union of two units (must reference the same model).
§Panics
Panics if the units reference different models.
Sourcepub fn intersection(&self, other: &Unit<'a>) -> Self
pub fn intersection(&self, other: &Unit<'a>) -> Self
Intersection of two units (must reference the same model).
§Panics
Panics if the units reference different models.
Sourcepub fn difference(&self, other: &Unit<'a>) -> Self
pub fn difference(&self, other: &Unit<'a>) -> Self
Difference of two units: atoms in self but not in other.
§Panics
Panics if the units reference different models.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Unit<'a>
impl<'a> RefUnwindSafe for Unit<'a>
impl<'a> Send for Unit<'a>
impl<'a> Sync for Unit<'a>
impl<'a> Unpin for Unit<'a>
impl<'a> UnsafeUnpin for Unit<'a>
impl<'a> UnwindSafe for Unit<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more