Struct chemfiles::Match[][src]

pub struct Match { /* fields omitted */ }

A Match is a set of atomic indexes matching a given selection. It can mostly be used like a &[usize].

Implementations

impl Match[src]

pub fn len(&self) -> usize[src]

Get the length of the Match.

Example

let atomic_match = Match::new(&[3, 4, 5]);
assert_eq!(atomic_match.len(), 3);

pub fn new(atoms: &[usize]) -> Match[src]

Create a new match containing the atoms in the atoms slice.

Panics

If the slice contains more than 4 elements, which is the maximal size of a match.

Example

let atomic_match = Match::new(&[3, 4, 5]);
assert_eq!(atomic_match.len(), 3);
assert_eq!(atomic_match[0], 3);
assert_eq!(atomic_match[1], 4);
assert_eq!(atomic_match[2], 5);

pub fn iter(&self) -> Iter<'_, usize>[src]

Iterate over the atomic indexes in the match.

Example

let atomic_match = Match::new(&[3, 4, 5]);
let mut iter = atomic_match.iter();

assert_eq!(iter.next(), Some(&3));
assert_eq!(iter.next(), Some(&4));
assert_eq!(iter.next(), Some(&5));
assert_eq!(iter.next(), None);

Trait Implementations

impl Clone for Match[src]

impl Debug for Match[src]

impl Index<usize> for Match[src]

type Output = usize

The returned type after indexing.

impl<'a> IntoIterator for &'a Match[src]

type Item = &'a usize

The type of the elements being iterated over.

type IntoIter = Iter<'a, usize>

Which kind of iterator are we turning this into?

impl PartialEq<Match> for Match[src]

impl Eq for Match[src]

impl StructuralEq for Match[src]

impl StructuralPartialEq for Match[src]

Auto Trait Implementations

impl RefUnwindSafe for Match

impl Send for Match

impl Sync for Match

impl Unpin for Match

impl UnwindSafe for Match

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.