mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
24 lines
501 B
Rust
24 lines
501 B
Rust
use std::marker::PhantomData;
|
|
|
|
pub struct Directed;
|
|
pub struct Undirected;
|
|
|
|
pub struct Graph<N, E, Ty = Directed> {
|
|
nodes: Vec<PhantomData<N>>,
|
|
edges: Vec<PhantomData<E>>,
|
|
ty: PhantomData<Ty>,
|
|
}
|
|
|
|
|
|
impl<N, E> Graph<N, E, Directed> {
|
|
pub fn new() -> Self {
|
|
Graph{nodes: Vec::new(), edges: Vec::new(), ty: PhantomData}
|
|
}
|
|
}
|
|
|
|
impl<N, E> Graph<N, E, Undirected> {
|
|
pub fn new_undirected() -> Self {
|
|
Graph{nodes: Vec::new(), edges: Vec::new(), ty: PhantomData}
|
|
}
|
|
}
|