message: Formatting fixes and more lcov.info sections
diff: use crate::config::Config;
  use crate::errors::RunError;
  -use crate::traces::{TraceMap, CoverageStat};
  +use crate::traces::{CoverageStat, TraceMap};
  use std::fs::File;
  use std::io::Write;
  @@ -22,16 +22,18 @@ pub fn export(coverage_data: &TraceMap, config: &Config) -> Result<(), RunError>
  let mut fns: Vec<String> = vec![];
  let mut fnda: Vec<String> = vec![];
  - let mut da: Vec<String> = vec![];
  + let mut da: Vec<(u64, u64)> = vec![];
  for trace in traces {
  if trace.fn_name.is_some() {
  let fn_name = trace.fn_name.clone().unwrap();
  let fn_hits = match trace.stats {
  CoverageStat::Line(hits) => hits,
  - _ => return Err(RunError::Info(
  + _ => {
  + return Err(RunError::Info(
  "Function doesn't have hits number".to_string(),
  - )),
  + ))
  + }
  };
  fns.push(format!("FN:{},{}", trace.line, fn_name));
  @@ -39,10 +41,8 @@ pub fn export(coverage_data: &TraceMap, config: &Config) -> Result<(), RunError>
  }
  match trace.stats {
  - CoverageStat::Line(hits) => {
  - da.push(format!("DA:{},{}", trace.line, hits))
  - },
  - _ => ()
  + CoverageStat::Line(hits) => da.push((trace.line, hits)),
  + _ => (),
  };
  }
  @@ -56,10 +56,23 @@ pub fn export(coverage_data: &TraceMap, config: &Config) -> Result<(), RunError>
  writeln!(file, "{}", fnda_line)?;
  }
  - for da_line in da {
  - writeln!(file, "{}", da_line)?;
  + for (line, hits) in da.iter() {
  + writeln!(file, "DA:{},{}", line, hits)?;
  }
  + writeln!(file, "LF:{}", da.len())?;
  + writeln!(
  + file,
  + "LH:{}",
  + da.iter().filter(|(_, hits)| *hits != 0).count()
  + )?;
  +
  + // TODO: add support for branching
  + // BRDA (BRDA:<line number>,<block number>,<branch number>,<hits>)
  + // BRF (branches found)
  + // BRH (branches hit)
  + // More at http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php
  +
  writeln!(file, "end_of_record")?;
  }
  