1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
use super::{Record, RecordKind}; use std::fmt::{Display, Formatter, Result}; impl Display for RecordKind { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, "{}", self.as_str()) } } impl Display for Record { fn fmt(&self, f: &mut Formatter) -> Result { use Record::*; let kind = self.kind(); match *self { TestName { ref name } => write!(f, "{}:{}", kind, name)?, SourceFile { ref path } => write!(f, "{}:{}", kind, path.display())?, FunctionName { ref name, start_line, } => write!(f, "{}:{},{}", kind, start_line, name)?, FunctionData { ref name, count } => write!(f, "{}:{},{}", kind, count, name)?, FunctionsFound { found } | BranchesFound { found } | LinesFound { found } => { write!(f, "{}:{}", kind, found)? } FunctionsHit { hit } | BranchesHit { hit } | LinesHit { hit } => { write!(f, "{}:{}", kind, hit)? } BranchData { line, block, branch, taken: Some(taken), } => write!(f, "{}:{},{},{},{}", kind, line, block, branch, taken)?, BranchData { line, block, branch, taken: None, } => write!(f, "{}:{},{},{},-", kind, line, block, branch)?, LineData { line, count, checksum: Some(ref checksum), } => write!(f, "{}:{},{},{}", kind, line, count, checksum)?, LineData { line, count, checksum: None, } => write!(f, "{}:{},{}", kind, line, count)?, EndOfRecord => write!(f, "{}", kind)?, } Ok(()) } }