pub(crate) fn front_matter(&'a self) -> Fallible<Option<Frontmatter>> {
        let root = self.root()?;

        for (i, node) in root.children().enumerate() {
            {
                let children = node.children().collect::<Vec<_>>().len();
                let descendants = node.descendants().collect::<Vec<_>>().len();
                let debug = format!("{:#?}", node.data.borrow().value);
                let ty = debug
                    .split(&['(', ' '][..])
                    .nth(0)
                    .ok_or_else(|| format!("error extracting type from '{}'", debug))
                    .map_err(anyhow::Error::msg)?;
                trace!(
                    "[{}] {} with {} child(ren) and {} descendant(s)",
                    i,
                    ty,
                    children,
                    descendants
                );
            }

            match &mut node.data.borrow_mut().value {
                &mut NodeValue::FrontMatter(ref fm) => {
                    let fm_str = String::from_utf8(fm.to_vec())?
                        .replace("---", "")
                        .trim()
                        .to_owned();

                    let fm: Frontmatter = if fm_str.is_empty() {
                        Frontmatter::default()
                    } else {
                        serde_yaml::from_str(&fm_str)?
                    };

                    trace!(
                        "[{}] found a YAML front matter: {:#?}\nsource string: \n'{}'",
                        i,
                        fm,
                        fm_str
                    );

                    return Ok(Some(fm));
                }

                // we're only interested in the frontmatter here
                _ => {}
            }
        }

        Ok(None)
    }
/// Find and parse the frontmatter of this crate's changelog file.
Find and parse the frontmatter of this crate's changelog file.
Find and parse the frontmatter of this crate ' s changelog file .
pub(crate) fn front_matter(&'a self) -> Fallible<Option<Frontmatter>> {
        let root = self.root()?;
        for (i, node) in root.children().enumerate() {
            {
                let children = node.children().collect::<Vec<_>>().len();
                let descendants = node.descendants().collect::<Vec<_>>().len();
                let debug = format!("{:#?}", node.data.borrow().value);
                let ty = debug
                    .split(&['(', ' '][..])
                    .nth(0)
                    .ok_or_else(|| format!("error extracting type from '{}'", debug))
                    .map_err(anyhow::Error::msg)?;
                trace!(
                    "[{}] {} with {} child(ren) and {} descendant(s)",
                    i,
                    ty,
                    children,
                    descendants
                );
            }
            match &mut node.data.borrow_mut().value {
                &mut NodeValue::FrontMatter(ref fm) => {
                    let fm_str = String::from_utf8(fm.to_vec())?
                        .replace("---", "")
                        .trim()
                        .to_owned();
                    let fm: Frontmatter = if fm_str.is_empty() {
                        Frontmatter::default()
                    } else {
                        serde_yaml::from_str(&fm_str)?
                    };
                    trace!(
                        "[{}] found a YAML front matter: {:#?}\nsource string: \n'{}'",
                        i,
                        fm,
                        fm_str
                    );
                    return Ok(Some(fm));
                }
                // we're only interested in the frontmatter here
                _ => {}
            }
        }
        Ok(None)
    }
pub ( crate ) fn front_matter ( & ' a self ) -> Fallible < Option < Frontmatter > > { let root = self . root ( ) ? ; for ( i , node ) in root . children ( ) . enumerate ( ) { { let children = node . children ( ) . collect :: < Vec < _ > > ( ) . len ( ) ; let descendants = node . descendants ( ) . collect :: < Vec < _ > > ( ) . len ( ) ; let debug = format ! ( " " node data borrow ( ) value ) ; let ty = debug . split ( & [ '(' , ' ' ] [ .. ] ) . nth ( 0 ) . ok_or_else ( | | format ! ( " " debug ) ) . map_err ( anyhow :: Error :: msg ) ? ; trace ! ( " " i ty children descendants ) ; } match & mut node . data . borrow_mut ( ) . value { & mut NodeValue :: FrontMatter ( ref fm ) => { let fm_str = String :: from_utf8 ( fm . to_vec ( ) ) ? . replace ( " " , " " ) . trim ( ) . to_owned ( ) ; let fm : Frontmatter = if fm_str . is_empty ( ) { Frontmatter :: default ( ) } else { serde_yaml :: from_str ( & fm_str ) ? } ; trace ! ( " \n \n " i fm fm_str ) ; return Ok ( Some ( fm ) ) ; } // we're only interested in the frontmatter here _ => { } } } Ok ( None ) }
Find and parse the frontmatter of this crate's changelog file.
Find and parse the frontmatter of this crate ' s changelog file .
&'a self
&'a self