Skip to content

Commit 71489a6

Browse files
committed
Got the edoc-test passing...
1 parent 88d1bfd commit 71489a6

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

vcf/src/vcf.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ impl From<parse::ParseError> for VCFError {
109109
/// Similarly, we can obtain the format information for a file via the `format` attribute.
110110
///
111111
/// ```
112+
/// use std::collections::HashMap;
112113
/// use vcf::vcf::parse_vcf;
114+
/// use vcf::{Header, HeaderValue};
113115
/// let vcf_source = br#"##fileformat=VCFv4.4
114116
/// ###fileDate=20090805
115117
/// ###source=myImputationProgramV3.1
@@ -139,10 +141,24 @@ impl From<parse::ParseError> for VCFError {
139141
/// let vcf = parse_vcf(&vcf_source[..])?;
140142
/// let hq_description = vcf.format
141143
/// .iter()
142-
/// .find(|item| match item.get("ID") {Some("HQ") => true, _ => false})
143-
/// .and_then(|item| item.get("Description"))
144-
/// .unwrap();
145-
/// assert_eq!(hq_description, "Haplotype Quality");
144+
/// .find(
145+
/// |item| match &item.value {
146+
/// HeaderValue::Nested(d) => match d.get("ID") {Some(v) => v == "HQ", _ => false},
147+
/// _ => false
148+
/// }
149+
/// ).unwrap();
150+
/// assert_eq!(
151+
/// *hq_description,
152+
/// Header {
153+
/// key: "FORMAT".to_string(),
154+
/// value: HeaderValue::Nested(HashMap::from([
155+
/// ("ID".to_string(), "HQ".to_string()),
156+
/// ("Number".to_string(), "2".to_string()),
157+
/// ("Type".to_string(), "Integer".to_string()),
158+
/// ("Description".to_string(), "Haplotype Quality".to_string()),
159+
/// ]))
160+
/// }
161+
/// );
146162
///# Ok::<(), VCFError>(())
147163
/// ```
148164
pub fn parse_vcf(source: impl BufRead) -> Result<VCF, VCFError> {

0 commit comments

Comments
 (0)