pub fn assert_link_order<'g>(
    links: impl IntoIterator<Item = PackageLink<'g>>,
    initial: impl IntoIterator<Item = &'g PackageId>,
    desc: impl Into<DirectionDesc<'g>>,
    msg: &str,
) {
    let desc = desc.into();

    // for forward, 'from' is known and 'to' is variable.
    let mut variable_seen: HashSet<_> = initial.into_iter().collect();

    for link in links {
        let known_id = desc.known_metadata(&link).id();
        let variable_id = desc.variable_metadata(&link).id();

        variable_seen.insert(variable_id);
        assert!(
            variable_seen.contains(&known_id),
            "{}: for package '{}': unexpected link {} package seen before any links {} package",
            msg,
            &known_id,
            desc.known_desc,
            desc.variable_desc,
        );
    }
}
Assert that links are presented in the expected order.

For any given package not in the initial set:
* If direction is Forward, the package should appear in the `to` of a link at least once
before it appears in the `from` of a link.
* If direction is Reverse, the package should appear in the `from` of a link at least once
before it appears in the `to` of a link.
fixtures/src/dep_helpers.rs