[][src]Struct chemfiles::ResidueRef

pub struct ResidueRef<'a> { /* fields omitted */ }

An analog to a reference to a residue (&Residue)

Methods from Deref<Target = Residue>

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

Get the number of atoms in this residue.

Example

let mut residue = Residue::new("water");
assert_eq!(residue.size(), 0);

residue.add_atom(0);
residue.add_atom(1);
residue.add_atom(2);
assert_eq!(residue.size(), 3);

pub fn id(&self) -> Option<i64>[src]

Get the identifier of this residue in the initial topology file.

Example

let residue = Residue::with_id("", 42);
assert_eq!(residue.id(), Some(42));

pub fn name(&self) -> String[src]

Get the name of this residue.

Example

let residue = Residue::new("water");
assert_eq!(residue.name(), "water");

pub fn contains(&self, atom: usize) -> bool[src]

Check if the atom at index i is in this residue

Example

let mut residue = Residue::new("water");
assert_eq!(residue.contains(56), false);

residue.add_atom(56);
assert_eq!(residue.contains(56), true);

pub fn atoms(&self) -> Vec<usize>[src]

Get the list of atoms of this residue.

Example

let mut residue = Residue::new("water");
assert_eq!(residue.atoms(), vec![]);

residue.add_atom(56);
assert_eq!(residue.atoms(), vec![56]);

pub fn get(&self, name: &str) -> Option<Property>[src]

Get a property with the given name in this frame, if it exist.

Examples

let mut residue = Residue::new("ALA");
residue.set("foo", Property::Double(22.2));

assert_eq!(residue.get("foo"), Some(Property::Double(22.2)));
assert_eq!(residue.get("Bar"), None);

pub fn properties(&self) -> PropertiesIter<'_>

Notable traits for PropertiesIter<'a>

impl<'a> Iterator for PropertiesIter<'a> type Item = (String, Property);
[src]

Get an iterator over all (name, property) pairs for this frame

Examples

let mut residue = Residue::new("ALA");
residue.set("foo", Property::Double(22.2));
residue.set("bar", Property::Bool(false));

for (name, property) in residue.properties() {
    if name == "foo" {
        assert_eq!(property, Property::Double(22.2));
    } else if name == "bar" {
        assert_eq!(property, Property::Bool(false));
    }
}

Trait Implementations

impl<'a> Deref for ResidueRef<'a>[src]

type Target = Residue

The resulting type after dereferencing.

Auto Trait Implementations

impl<'a> RefUnwindSafe for ResidueRef<'a>

impl<'a> !Send for ResidueRef<'a>

impl<'a> !Sync for ResidueRef<'a>

impl<'a> Unpin for ResidueRef<'a>

impl<'a> UnwindSafe for ResidueRef<'a>

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, 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.