Trait Buildable

Source
pub trait Buildable
where Self: Sized,
{ type Builder: Builder<Graph = Self>; // Provided methods fn new_builder() -> Self::Builder { ... } fn new_with<F>(f: F) -> Self where F: FnOnce(&mut Self::Builder) { ... } }
Expand description

A graph with a default builder.

Required Associated Types§

Source

type Builder: Builder<Graph = Self>

Provided Methods§

Source

fn new_builder() -> Self::Builder

Create a new builder for this graph type.

Source

fn new_with<F>(f: F) -> Self
where F: FnOnce(&mut Self::Builder),

Create a new graph by passing the builder to the callback f.

§Example
use rs_graph::{Buildable, Builder, LinkedListGraph};
use rs_graph::traits::FiniteGraph;

let g = LinkedListGraph::<usize>::new_with(|b| {
    let u = b.add_node();
    let v = b.add_node();
    b.add_edge(u, v);
});

assert_eq!(g.num_nodes(), 2);
assert_eq!(g.num_edges(), 1);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<ID> Buildable for VecGraph<ID>
where ID: PrimInt + Unsigned,

Source§

impl<ID, N, E> Buildable for LinkedListGraph<ID, N, E>
where ID: PrimInt + Unsigned + 'static, N: Default, E: Default,