summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseancarroll <seanc28@gmail.com>2020-12-12 23:04:35 -0600
committerseancarroll <seanc28@gmail.com>2020-12-12 23:04:35 -0600
commit7bfe8147c485d20e252e2afe596784d5ce623ba4 (patch)
tree3552517981994bf5c9fd4821de0a0487947fdddf
parentc5f74105b37f347082a304cffe78c35f8922df2b (diff)
downloaddotavious-7bfe8147c485d20e252e2afe596784d5ce623ba4.zip
use Self for NodeBuilder::new which feels a bit cleaner
-rw-r--r--src/lib.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 3a6ff5a..f9ac804 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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);