From c3a01f5353013b82ec3048969f48e1f229a88c48 Mon Sep 17 00:00:00 2001 From: seancarroll Date: Sat, 9 Jan 2021 22:44:40 -0600 Subject: cargo fmt --- src/attributes/port_position.rs | 10 ++++++---- src/attributes/rectangle.rs | 17 ++++++++++------- src/dot.rs | 27 ++++++++++----------------- src/lib.rs | 1 - 4 files changed, 26 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/attributes/port_position.rs b/src/attributes/port_position.rs index 8900219..1948b8e 100644 --- a/src/attributes/port_position.rs +++ b/src/attributes/port_position.rs @@ -37,7 +37,7 @@ impl<'a> DotString<'a> for PortPosition { #[cfg(test)] mod test { - use crate::attributes::{PortPosition, CompassPoint}; + use crate::attributes::{CompassPoint, PortPosition}; use crate::DotString; #[test] @@ -47,14 +47,16 @@ mod test { PortPosition::Port { port_name: "port_0".to_string(), compass_point: None - }.dot_string() + } + .dot_string() ); assert_eq!( "port_0:ne", PortPosition::Port { port_name: "port_0".to_string(), compass_point: Some(CompassPoint::NE) - }.dot_string() + } + .dot_string() ); } @@ -62,4 +64,4 @@ mod test { fn compass_dot_string() { assert_eq!("ne", PortPosition::Compass(CompassPoint::NE).dot_string()); } -} \ No newline at end of file +} diff --git a/src/attributes/rectangle.rs b/src/attributes/rectangle.rs index 9b36ee2..acf9ae1 100644 --- a/src/attributes/rectangle.rs +++ b/src/attributes/rectangle.rs @@ -19,15 +19,18 @@ impl<'a> DotString<'a> for Rectangle { #[cfg(test)] mod test { - use crate::attributes::{Rectangle, Point}; + use crate::attributes::{Point, Rectangle}; use crate::DotString; #[test] fn dot_string() { - assert_eq!("0.0,0.0,1.0,1.0", Rectangle { - lower_left: Point::new_2d(0.0, 0.0), - upper_right: Point::new_2d(1.0, 1.0) - }.dot_string()); + assert_eq!( + "0.0,0.0,1.0,1.0", + Rectangle { + lower_left: Point::new_2d(0.0, 0.0), + upper_right: Point::new_2d(1.0, 1.0) + } + .dot_string() + ); } - -} \ No newline at end of file +} diff --git a/src/dot.rs b/src/dot.rs index 634f24b..9b2d825 100644 --- a/src/dot.rs +++ b/src/dot.rs @@ -9,9 +9,9 @@ use crate::attributes::{ use indexmap::IndexMap; use std::borrow::Cow; use std::collections::HashMap; +use std::fmt::{Debug, Display, Formatter}; use std::io; use std::io::prelude::*; -use std::fmt::{Display, Formatter, Debug}; static INDENT: &str = " "; @@ -25,34 +25,32 @@ pub struct Dot<'a> { } impl<'a> Dot<'a> { - /// Renders directed graph `g` into the writer `w` in DOT syntax. + /// Renders graph into the writer `w` in DOT syntax. /// (Simple wrapper around `render_opts` that passes a default set of options.) - //pub fn render(self, g: Graph, w: &mut W) -> io::Result<()> pub fn render(self, w: &mut W) -> io::Result<()> where W: Write, { - // TODO: use default_options? self.render_opts(w, &[]) } - /// Renders directed graph `g` into the writer `w` in DOT syntax. + /// Renders graph into the writer `w` in DOT syntax. /// (Main entry point for the library.) - // pub fn render_opts(self, graph: Graph, w: &mut W, options: &[RenderOption]) -> io::Result<()> pub fn render_opts(self, w: &mut W, options: &[RenderOption]) -> io::Result<()> where W: Write, { - self.internal_render(&self.graph, w) + self.internal_render(&self.graph, w, options) } fn internal_render( &self, graph: &Graph, - w: &mut W + w: &mut W, + options: &[RenderOption], ) -> io::Result<()> - where - W: Write, + where + W: Write, { if let Some(comment) = &graph.comment { // TODO: split comment into lines of 80 or so characters @@ -125,8 +123,8 @@ impl<'a> Dot<'a> { impl<'a> Display for Dot<'a> { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { - let mut writer= Vec::new(); - self.internal_render(&self.graph, &mut writer).unwrap(); + let mut writer = Vec::new(); + self.internal_render(&self.graph, &mut writer, &[]).unwrap(); let mut s = String::new(); Read::read_to_string(&mut &*writer, &mut s).unwrap(); @@ -149,11 +147,6 @@ pub enum RenderOption { EdgeIndexLabel, } -/// Returns vec holding all the default render options. -pub fn default_options() -> Vec { - vec![] -} - pub struct Graph<'a> { pub id: Option, diff --git a/src/lib.rs b/src/lib.rs index 65d98c2..575e4cf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,7 +42,6 @@ //! } //! ``` - pub mod attributes; pub mod dot; -- cgit v1.2.3