Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/2a5f/dep-res
Simple dependency resolution
https://github.com/2a5f/dep-res
Last synced: 9 days ago
JSON representation
Simple dependency resolution
- Host: GitHub
- URL: https://github.com/2a5f/dep-res
- Owner: 2A5F
- License: mit
- Created: 2023-05-19T15:38:14.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-15T05:07:55.000Z (11 months ago)
- Last Synced: 2024-03-15T10:20:47.062Z (8 months ago)
- Language: Rust
- Homepage: https://crates.io/crates/dep-res
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dep-res
![Rust](https://github.com/2A5F/dep-res/workflows/Rust/badge.svg)
[![version](https://img.shields.io/crates/v/dep-res)](https://crates.io/crates/dep-res)
[![documentation](https://docs.rs/dep-res/badge.svg)](https://docs.rs/dep-res)
![LICENSE](https://img.shields.io/crates/l/dep-res)Simple dependency resolution
## Example
```rust
#[derive(Debug)]
struct SimpleDep {
pub id: usize,
pub deps: Vec,
}impl DepMeta for SimpleDep {
type Id = usize;fn get_id(&self) -> Self::Id {
self.id
}fn get_deps(&self) -> &[Self::Id] {
&*self.deps
}
}let items = vec![
SimpleDep {
id: 0,
deps: vec![],
},
SimpleDep {
id: 1,
deps: vec![0],
},
SimpleDep {
id: 2,
deps: vec![],
},
SimpleDep {
id: 3,
deps: vec![],
},
SimpleDep {
id: 4,
deps: vec![3],
},
SimpleDep {
id: 5,
deps: vec![4],
},
];let mut dr = DepRes::new();
dr.add(&items);
let r = dr.resolve().unwrap();let items = r.sorted_by_level();
println!("{:?}", items);
// [0, 2, 3, 1, 4, 5]let levels = r.iter_level().collect::>();
println!("{:?}", levels);
// // example, actually unordered
//
// [
// DepLevel { level: 0, deps: {0: (), 2: (), 3: ()} },
// DepLevel { level: 1, deps: {1: (), 4: ()} },
// DepLevel { level: 2, deps: {5: ()} },
// ]
```