fn split_content<'c>(file_path: &Path, content: &'c str) -> Result<(RawFrontMatter<'c>, &'c str)> {
    let (re, is_toml) = if TOML_RE.is_match(content) {
        (&TOML_RE as &Regex, true)
    } else if YAML_RE.is_match(content) {
        (&YAML_RE as &Regex, false)
    } else {
        bail!(
            "Couldn't find front matter in `{}`. Did you forget to add `+++` or `---`?",
            file_path.to_string_lossy()
        );
    };

    // 2. extract the front matter and the content
    let caps = re.captures(content).unwrap();
    // caps[0] is the full match
    // caps[1] => front matter
    // caps[2] => content
    let front_matter = caps.get(1).unwrap().as_str();
    let content = caps.get(2).unwrap().as_str();
    if is_toml {
        Ok((RawFrontMatter::Toml(front_matter), content))
    } else {
        Ok((RawFrontMatter::Yaml(front_matter), content))
    }
}
/// Split a file between the front matter and its content
/// Will return an error if the front matter wasn't found
Split a file between the front matter and its content
Will return an error if the front matter wasn't found
Split a file between the front matter and its content Will return an error if the front matter wasn ' t found
fn split_content<'c>(file_path: &Path, content: &'c str) -> Result<(RawFrontMatter<'c>, &'c str)> {
    let (re, is_toml) = if TOML_RE.is_match(content) {
        (&TOML_RE as &Regex, true)
    } else if YAML_RE.is_match(content) {
        (&YAML_RE as &Regex, false)
    } else {
        bail!(
            "Couldn't find front matter in `{}`. Did you forget to add `+++` or `---`?",
            file_path.to_string_lossy()
        );
    };
    // 2. extract the front matter and the content
    let caps = re.captures(content).unwrap();
    // caps[0] is the full match
    // caps[1] => front matter
    // caps[2] => content
    let front_matter = caps.get(1).unwrap().as_str();
    let content = caps.get(2).unwrap().as_str();
    if is_toml {
        Ok((RawFrontMatter::Toml(front_matter), content))
    } else {
        Ok((RawFrontMatter::Yaml(front_matter), content))
    }
}
fn split_content < ' c > ( file_path : & Path , content : & ' c str ) -> Result < ( RawFrontMatter < ' c > , & ' c str ) > { let ( re , is_toml ) = if TOML_RE . is_match ( content ) { ( & TOML_RE as & Regex , true ) } else if YAML_RE . is_match ( content ) { ( & YAML_RE as & Regex , false ) } else { bail ! ( " " file_path to_string_lossy ( ) ) ; } ; // 2. extract the front matter and the content let caps = re . captures ( content ) . unwrap ( ) ; // caps[0] is the full match // caps[1] => front matter // caps[2] => content let front_matter = caps . get ( 1 ) . unwrap ( ) . as_str ( ) ; let content = caps . get ( 2 ) . unwrap ( ) . as_str ( ) ; if is_toml { Ok ( ( RawFrontMatter :: Toml ( front_matter ) , content ) ) } else { Ok ( ( RawFrontMatter :: Yaml ( front_matter ) , content ) ) } }
Split a file between the front matter and its content
Will return an error if the front matter wasn't found
Split a file between the front matter and its content Will return an error if the front matter wasn ' t found
file_path
&Path
content
&'c str
file_path
&Path
content
&'c str