Crates.io | dep_crusher |
lib.rs | dep_crusher |
version | 0.1.2 |
source | src |
created_at | 2023-07-13 02:03:59.893266 |
updated_at | 2023-07-13 18:51:58.969044 |
description | Starting at a root node, traverse the dependency graph and flatten it. |
homepage | |
repository | https://github.com/Spencer1O1/dep-crusher/ |
max_upload_size | |
id | 914966 |
size | 6,455 |
Starting at a root node, traverse its entire dependency graph and flatten it into a top-to-bottom list. Nodes are a trait implementation, allowing dep_crusher to have generic, widespread use.
There are two easy installation options.
cargo add dep_crusher
Cargo.toml
file[dependencies]
dep_crusher = "0.1.0"
dep_crusher::dep_node::Node
trait:struct MyStruct {
// ...
}
impl PartialEq for MyStruct {
fn eq(&self, other: &Self) -> bool {
// Check equality with, for example, and ID
}
}
impl dep_crusher::dep_node::Node for MyStruct {
type Id = u64; // Type that implements Eq + Hash;
fn get_id(&self) -> Self::Id {
// Get a unique identifier of MyStruct
}
fn get_next(&self) -> Vec<Self> {
// Get and return the next Vec<MyStruct>
}
}
let my_struct = MyStruct {
// ...
}
let ordered_dependencies = my_struct.crush();
// OR
let ordered_dependencies = dep_crusher::crush(my_struct);
// Returns dep_crusher::result::Result<MyStruct>
// The Ok variant is Vec<MyStruct>
// The Error variant is dep_crusher::result::Error<MyStruct>
Pull requests are very welcome. Please feel free to make this better! For major updates, please open an issue first to discuss what you want to change.
Please make sure to update tests as appropriate.
MIT OR Apache-2.0