File: doc_interface.rs

package info (click to toggle)
rust-astral-pubgrub 0.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 532 kB
  • sloc: makefile: 2
file content (24 lines) | stat: -rw-r--r-- 867 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// SPDX-License-Identifier: MPL-2.0

use pubgrub::{OfflineDependencyProvider, Ranges, resolve};

type NumVS = Ranges<u32>;

// `root` depends on `menu` and `icons`
// `menu` depends on `dropdown`
// `dropdown` depends on `icons`
// `icons` has no dependency
#[rustfmt::skip]
fn main() {
    let mut dependency_provider = OfflineDependencyProvider::<&str, NumVS>::new();
    dependency_provider.add_dependencies(
        "root", 1u32, [("menu", Ranges::full()), ("icons", Ranges::full())],
    );
    dependency_provider.add_dependencies("menu", 1u32, [("dropdown", Ranges::full())]);
    dependency_provider.add_dependencies("dropdown", 1u32, [("icons", Ranges::full())]);
    dependency_provider.add_dependencies("icons", 1u32, []);

    // Run the algorithm.
    let solution = resolve(&dependency_provider, "root", 1u32);
    println!("Solution: {solution:?}");
}