pub struct Bond {
pub i: usize,
pub j: usize,
pub order: BondOrder,
}Expand description
A chemical bond between two atoms.
Represents a covalent bond with canonical ordering (i ≤ j) to ensure consistent hashing and equality comparisons. This allows bonds to be stored in hash-based collections without duplicates regardless of the order atoms are specified.
§Fields
i— Index of the first atom (always ≤ j)j— Index of the second atom (always ≥ i)order— Bond multiplicity (BondOrder)
§Examples
use dreid_forge::{Bond, BondOrder};
// Order is automatically canonicalized
let bond1 = Bond::new(5, 2, BondOrder::Single);
let bond2 = Bond::new(2, 5, BondOrder::Single);
assert_eq!(bond1.i, 2); // smaller index
assert_eq!(bond1.j, 5); // larger index
assert_eq!(bond1, bond2); // equivalent regardless of input orderFields§
§i: usizeIndex of the first atom (canonically the smaller index).
j: usizeIndex of the second atom (canonically the larger or equal index).
order: BondOrderBond order (single, double, triple, or aromatic).
Implementations§
Source§impl Bond
impl Bond
Sourcepub fn new(idx1: usize, idx2: usize, order: BondOrder) -> Self
pub fn new(idx1: usize, idx2: usize, order: BondOrder) -> Self
Creates a new bond with canonical atom ordering.
Automatically orders atom indices so that i ≤ j, ensuring
consistent representation regardless of the order arguments
are provided.
§Arguments
idx1— Index of the first atomidx2— Index of the second atomorder— Bond multiplicity
§Returns
A new Bond with canonically ordered indices.
Trait Implementations§
impl Eq for Bond
impl StructuralPartialEq for Bond
Auto Trait Implementations§
impl Freeze for Bond
impl RefUnwindSafe for Bond
impl Send for Bond
impl Sync for Bond
impl Unpin for Bond
impl UnsafeUnpin for Bond
impl UnwindSafe for Bond
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.