From 71489a6fa4d0a3284101a6ade385d7f1f484a02f Mon Sep 17 00:00:00 2001 From: ac <4184070+MrCurtis@users.noreply.github.com> Date: Wed, 16 Aug 2023 16:50:54 +0000 Subject: [PATCH] Got the edoc-test passing... --- vcf/src/vcf.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/vcf/src/vcf.rs b/vcf/src/vcf.rs index 89e8865..8cd2e23 100644 --- a/vcf/src/vcf.rs +++ b/vcf/src/vcf.rs @@ -109,7 +109,9 @@ impl From for VCFError { /// Similarly, we can obtain the format information for a file via the `format` attribute. /// /// ``` +/// use std::collections::HashMap; /// use vcf::vcf::parse_vcf; +/// use vcf::{Header, HeaderValue}; /// let vcf_source = br#"##fileformat=VCFv4.4 /// ###fileDate=20090805 /// ###source=myImputationProgramV3.1 @@ -139,10 +141,24 @@ impl From for VCFError { /// let vcf = parse_vcf(&vcf_source[..])?; /// let hq_description = vcf.format /// .iter() -/// .find(|item| match item.get("ID") {Some("HQ") => true, _ => false}) -/// .and_then(|item| item.get("Description")) -/// .unwrap(); -/// assert_eq!(hq_description, "Haplotype Quality"); +/// .find( +/// |item| match &item.value { +/// HeaderValue::Nested(d) => match d.get("ID") {Some(v) => v == "HQ", _ => false}, +/// _ => false +/// } +/// ).unwrap(); +/// assert_eq!( +/// *hq_description, +/// Header { +/// key: "FORMAT".to_string(), +/// value: HeaderValue::Nested(HashMap::from([ +/// ("ID".to_string(), "HQ".to_string()), +/// ("Number".to_string(), "2".to_string()), +/// ("Type".to_string(), "Integer".to_string()), +/// ("Description".to_string(), "Haplotype Quality".to_string()), +/// ])) +/// } +/// ); ///# Ok::<(), VCFError>(()) /// ``` pub fn parse_vcf(source: impl BufRead) -> Result {