Commit f5832f27 authored by NOEL Philippe's avatar NOEL Philippe

correct a borrow err in distance function in atom.rs

parent 642b84c6
......@@ -35,10 +35,10 @@ impl Atom {
/// let h1 = pdbparser::Atom::new(String::from("HT1"), 1, [1.0, 5.0, 2.0]);
/// let h2 = pdbparser::Atom::new(String::from("HT1"), 1, [11.0, 17.0, 5.0]);
///
/// assert_eq!(15.905973, h1.compute_distance(h2));
/// assert_eq!(15.905973, h1.compute_distance(&h2));
///
/// ````
pub fn compute_distance(&self, a: Atom) -> f32 {
pub fn compute_distance(&self, a: &Atom) -> f32 {
(
(self.coord[0] - a.coord[0]).powi(2) +
(self.coord[1] - a.coord[1]).powi(2) +
......
......@@ -50,7 +50,7 @@ impl<'a> Protein {
return true
}
}
return false
false
}
/// Return a mutable reference of a chaine with its name. Return None if the
......
......@@ -4,9 +4,7 @@ use std::io::BufReader;
use std::process;
use super::protein::Protein;
use super::chain::Chain;
use super::residue::Residue;
use super::atom::Atom;
/// Parse the string to return a f32. The `trim` is used to remove
/// /n and spaces.
......@@ -73,7 +71,7 @@ pub fn parse_pdb(f: &str) -> Protein {
let x = parse_float(&l[30..38].to_string());
let y = parse_float(&l[38..46].to_string());
let z = parse_float(&l[46..54].to_string());
protein.update_protein(chain.clone(), residue_name.clone(), residue_number as u64, atom_name.clone(), atom_number as u64, [x, y, z]);
protein.update_protein(chain, residue_name.clone(), residue_number as u64, atom_name.clone(), atom_number as u64, [x, y, z]);
}
}
protein
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment