mdbook-utils 0.1.3

Tools to manage links, reference definitions, and code examples in Markdown files, especially `mdbook` source directories.
Documentation
//! Merge existing reference definitions and new ones
//! and write the result to a file

use crate::link::Link;

/// Append, sort and dedupe reference definitions.
pub(crate) fn merge_links<'a>(
    existing_links: Vec<Link<'a>>,
    new_links: &mut Vec<Link<'a>>,
) -> Vec<Link<'a>> {
    let mut buf = existing_links.clone();
    buf.append(new_links);

    // `Link` has a custom Ord / Eq implementation,
    // thus we can sort them.
    buf.sort();
    buf.dedup();
    buf
}

#[cfg(test)]
mod test {
    // use super::*;

    // #[test]
    // fn test() {
    // }
}