Struct chemfiles::ResidueRef[][src]

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

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

Methods from Deref<Target = Residue>

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);

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

Example

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

Get the name of this residue.

Example

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

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);

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]);

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);

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

The resulting type after dereferencing.

Dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.