Struct acetylene_parser::types::Substance [] [src]

pub struct Substance {
    pub symbol: String,
    pub quantity: u32,
    pub charge: Option<i32>,
    pub groups: Option<Box<Vec<Substance>>>,
}

The type this module spins on.

Right now it's very, very sparse. I want to make sure I can get the basics right before I go chasing after isomers and isotopes and so on.

The main thing to note is that groups, the optional member describing the functional groups of a Substance, is Boxed (heap allocation). That's to prevent the infinite recursion of allocating memory for groups on the stack.

This means that accessing the functional groups requires an access, an unwrap/Option check, and then a dereference. Wheee!

Examples

Here's an (blithe, reckless, unwrapping) example of group access:

use acetylene_parser::tokenize;
use acetylene_parser::types::Substance;

let benzene_ring = r"c1ccccc1";
let res = tokenize(benzene_ring, "smiles");
 
println!("Main substance: {:?}", &res.symbol);
println!("Groups: ");
for sub in *(res.groups.unwrap()) {
  println!("{:?}", sub);
}

Fields

Trait Implementations

impl Debug for Substance
[src]

Formats the value using the given formatter.

impl Eq for Substance
[src]

impl Clone for Substance
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Substance
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.