dot2/kind.rs
1/// Graph kind determines if `digraph` or `graph` is used as keyword
2/// for the graph.
3#[derive(Copy, Clone, PartialEq, Eq, Debug)]
4pub enum Kind {
5 Digraph,
6 Graph,
7}
8
9impl Kind {
10 /// The edgeop syntax to use for this graph kind.
11 pub(crate) fn edgeop(&self) -> &'static str {
12 match *self {
13 Self::Digraph => "->",
14 Self::Graph => "--",
15 }
16 }
17}
18
19impl std::fmt::Display for Kind {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 let s = match *self {
22 Self::Digraph => "digraph",
23 Self::Graph => "graph",
24 };
25
26 write!(f, "{s}")
27 }
28}