pub struct Terminal { /* private fields */ }Implementations§
Source§impl Terminal
impl Terminal
Sourcepub fn new(contents: &str) -> Self
pub fn new(contents: &str) -> Self
Examples found in repository?
More examples
examples/stacked.rs (line 7)
5fn main() {
6 let diagram = Diagram::default()
7 .push(Box::new(Terminal::new("CREATE")))
8 .push(Box::new(Terminal::new("VIRTUAL")))
9 .push(Box::new(Terminal::new("TABLE")))
10 .push(Box::new(
11 Optional::new(Box::new(
12 Sequence::default()
13 .push(Box::new(Terminal::new("IF")))
14 .push(Box::new(Terminal::new("NOT")))
15 .push(Box::new(Terminal::new("EXISTS")))
16 ))
17 ))
18 .next_row()
19 .push(Box::new(
20 Optional::new(Box::new(
21 Sequence::default()
22 .push(Box::new(NonTerminal::new("schema-name")))
23 .push(Box::new(Terminal::new(".")))
24 ))
25 ))
26 .push(Box::new(NonTerminal::new("table-name")))
27 .next_row()
28 .push(Box::new(Terminal::new("USING")))
29 .push(Box::new(NonTerminal::new("module-name")))
30 .push(Box::new(
31 Optional::new(Box::new(
32 Sequence::default()
33 .push(Box::new(Terminal::new("(")))
34 .push(Box::new(
35 Repeat::new(Box::new(
36 NonTerminal::new("module-argument")
37 ))
38 ))
39 .push(Box::new(Terminal::new(")")))
40 ))
41 ));
42 println!("{}", diagram);
43}examples/json.rs (line 7)
5fn main() {
6 let object = Diagram::default()
7 .push(Box::new(Terminal::new("{")))
8 .push(Box::new(
9 Optional::new(Box::new(
10 Sequence::default()
11 .push(Box::new(
12 Repeat::new(Box::new(
13 Sequence::default()
14 .push(Box::new(NonTerminal::new("string")))
15 .push(Box::new(Terminal::new(":")))
16 .push(Box::new(NonTerminal::new("value")))
17 .push(Box::new(Terminal::new(",")))
18 ))
19 ))
20 .push(Box::new(
21 Sequence::default()
22 .push(Box::new(NonTerminal::new("string")))
23 .push(Box::new(Terminal::new(":")))
24 .push(Box::new(NonTerminal::new("value")))
25 ))
26 ))
27 ))
28 .push(Box::new(Terminal::new("}")));
29 println!("object:\n{}\n", object);
30
31 let array = Diagram::default()
32 .push(Box::new(Terminal::new("[")))
33 .push(Box::new(
34 Optional::new(Box::new(
35 Sequence::default()
36 .push(Box::new(
37 Repeat::new(Box::new(
38 Sequence::default()
39 .push(Box::new(NonTerminal::new("value")))
40 .push(Box::new(Terminal::new(",")))
41 ))
42 ))
43 .push(Box::new(NonTerminal::new("value")))
44 ))
45 ))
46 .push(Box::new(Terminal::new("]")));
47 println!("array:\n{}\n", array);
48
49 let value = Diagram::default()
50 .push(Box::new(
51 Choice::default()
52 .push(Box::new(NonTerminal::new("string")))
53 .push(Box::new(NonTerminal::new("number")))
54 .push(Box::new(NonTerminal::new("object")))
55 .push(Box::new(NonTerminal::new("array")))
56 .push(Box::new(Terminal::new("true")))
57 .push(Box::new(Terminal::new("false")))
58 .push(Box::new(Terminal::new("null")))
59 ));
60 println!("value:\n{}\n", value);
61
62 let string = Diagram::default()
63 .push(Box::new(Terminal::new("\"")))
64 .push(Box::new(
65 Repeat::new(Box::new(
66 Choice::default()
67 .push(Box::new(Terminal::new("Any unicode character except \" or \\ or control character")))
68 .push(Box::new(
69 Sequence::default()
70 .push(Box::new(Terminal::new("\\")))
71 .push(Box::new(
72 Choice::default()
73 .push(Box::new(Terminal::new("\"")))
74 .push(Box::new(Terminal::new("\\")))
75 .push(Box::new(Terminal::new("/")))
76 .push(Box::new(Terminal::new("b")))
77 .push(Box::new(Terminal::new("f")))
78 .push(Box::new(Terminal::new("n")))
79 .push(Box::new(Terminal::new("r")))
80 .push(Box::new(Terminal::new("t")))
81 .push(Box::new(
82 Sequence::default()
83 .push(Box::new(Terminal::new("u")))
84 .push(Box::new(
85 Repeat::new(Box::new(Terminal::new("hexadecimal digit")))
86 .min(4)
87 .max(4)
88 ))
89 ))
90 ))
91 ))
92 ))
93 ))
94 .push(Box::new(Terminal::new("\"")));
95 println!("string:\n{}\n", string);
96
97 let number = Diagram::default()
98 .push(Box::new(Optional::new(Box::new(Terminal::new("-")))))
99 .push(Box::new(
100 Choice::default()
101 .push(Box::new(Terminal::new("0")))
102 .push(Box::new(
103 Sequence::default()
104 .push(Box::new(Terminal::new("digit 1-9")))
105 .push(Box::new(
106 Repeat::new(Box::new(Terminal::new("digit")))
107 ))
108 ))
109 ))
110 .push(Box::new(
111 Optional::new(Box::new(
112 Sequence::default()
113 .push(Box::new(Terminal::new(".")))
114 .push(Box::new(
115 Repeat::new(Box::new(Terminal::new("digit")))
116 .min(1)
117 ))
118 ))
119 ))
120 .push(Box::new(
121 Optional::new(Box::new(
122 Sequence::default()
123 .push(Box::new(
124 Choice::default()
125 .push(Box::new(Terminal::new("e")))
126 .push(Box::new(Terminal::new("E")))
127 ))
128 .push(Box::new(
129 Optional::new(Box::new(
130 Choice::default()
131 .push(Box::new(Terminal::new("+")))
132 .push(Box::new(Terminal::new("-")))
133 ))
134 ))
135
136 .push(Box::new(
137 Repeat::new(Box::new(Terminal::new("digit")))
138 .min(1)
139 ))
140 ))
141 ));
142 println!("number:\n{}", number);
143}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Terminal
impl RefUnwindSafe for Terminal
impl Send for Terminal
impl Sync for Terminal
impl Unpin for Terminal
impl UnsafeUnpin for Terminal
impl UnwindSafe for Terminal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more