diff options
author | seancarroll <seanc28@gmail.com> | 2020-12-12 23:04:35 -0600 |
---|---|---|
committer | seancarroll <seanc28@gmail.com> | 2020-12-12 23:04:35 -0600 |
commit | 7bfe8147c485d20e252e2afe596784d5ce623ba4 (patch) | |
tree | 3552517981994bf5c9fd4821de0a0487947fdddf | |
parent | c5f74105b37f347082a304cffe78c35f8922df2b (diff) | |
download | dotavious-7bfe8147c485d20e252e2afe596784d5ce623ba4.zip |
use Self for NodeBuilder::new which feels a bit cleaner
-rw-r--r-- | src/lib.rs | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -520,13 +520,10 @@ pub struct NodeBuilder<'a> { } impl<'a> NodeBuilder<'a> { - pub fn new(id: String) -> NodeBuilder<'a> { - NodeBuilder { + pub fn new(id: String) -> Self { + Self { id: id, port: None, - // compass: None, - // shape: None, - // label: None, attributes: HashMap::new(), } } @@ -812,8 +809,9 @@ fn single_node() { #[test] fn single_node_with_style() { let mut g = Graph::new(Some("single_node".to_string())); - let mut nb = NodeBuilder::new("N0".to_string()); - let node = nb.attribute("style", AttributeText::quotted("dashed")).build(); + let node = NodeBuilder::new("N0".to_string()) + .attribute("style", AttributeText::quotted("dashed")) + .build(); g.add_node(node); |