]> git.lizzy.rs Git - rust.git/blobdiff - src/libgraphviz/lib.rs
Add some type-alias-impl-trait regression tests
[rust.git] / src / libgraphviz / lib.rs
index a34e4fb89ff27457ea5b21ec033438c50f21927f..d04f5c1d4ee77228e9ea7bd8e8b5dbc2bd81d01c 100644 (file)
 //!
 //! * [DOT language](http://www.graphviz.org/doc/info/lang.html)
 
-#![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
-       test(attr(allow(unused_variables), deny(warnings))))]
-
-#![deny(rust_2018_idioms)]
-
+#![doc(
+    html_root_url = "https://doc.rust-lang.org/nightly/",
+    test(attr(allow(unused_variables), deny(warnings)))
+)]
 #![feature(nll)]
 
 use LabelText::*;
 
 use std::borrow::Cow;
-use std::io::prelude::*;
 use std::io;
+use std::io::prelude::*;
 
 /// The text for a graphviz label on a node or edge.
 pub enum LabelText<'a> {
@@ -404,7 +403,7 @@ pub fn new<Name: Into<Cow<'a, str>>>(name: Name) -> Result<Id<'a>, ()> {
             Some(c) if c.is_ascii_alphabetic() || c == '_' => {}
             _ => return Err(()),
         }
-        if !name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_' ) {
+        if !name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
             return Err(());
         }
 
@@ -477,10 +476,7 @@ fn edge_style(&'a self, _e: &Self::Edge) -> Style {
 /// Escape tags in such a way that it is suitable for inclusion in a
 /// Graphviz HTML label.
 pub fn escape_html(s: &str) -> String {
-    s.replace("&", "&amp;")
-     .replace("\"", "&quot;")
-     .replace("<", "&lt;")
-     .replace(">", "&gt;")
+    s.replace("&", "&amp;").replace("\"", "&quot;").replace("<", "&lt;").replace(">", "&gt;")
 }
 
 impl<'a> LabelText<'a> {
@@ -497,7 +493,8 @@ pub fn html<S: Into<Cow<'a, str>>>(s: S) -> LabelText<'a> {
     }
 
     fn escape_char<F>(c: char, mut f: F)
-        where F: FnMut(char)
+    where
+        F: FnMut(char),
     {
         match c {
             // not escaping \\, since Graphviz escString needs to
@@ -561,8 +558,8 @@ pub fn suffix_line(self, suffix: LabelText<'_>) -> LabelText<'static> {
     }
 }
 
-pub type Nodes<'a,N> = Cow<'a,[N]>;
-pub type Edges<'a,E> = Cow<'a,[E]>;
+pub type Nodes<'a, N> = Cow<'a, [N]>;
+pub type Edges<'a, E> = Cow<'a, [E]>;
 
 // (The type parameters in GraphWalk should be associated items,
 // when/if Rust supports such.)
@@ -609,25 +606,24 @@ pub fn default_options() -> Vec<RenderOption> {
 
 /// Renders directed graph `g` into the writer `w` in DOT syntax.
 /// (Simple wrapper around `render_opts` that passes a default set of options.)
-pub fn render<'a,N,E,G,W>(g: &'a G, w: &mut W) -> io::Result<()>
-    where N: Clone + 'a,
-          E: Clone + 'a,
-          G: Labeller<'a, Node=N, Edge=E> + GraphWalk<'a, Node=N, Edge=E>,
-          W: Write
+pub fn render<'a, N, E, G, W>(g: &'a G, w: &mut W) -> io::Result<()>
+where
+    N: Clone + 'a,
+    E: Clone + 'a,
+    G: Labeller<'a, Node = N, Edge = E> + GraphWalk<'a, Node = N, Edge = E>,
+    W: Write,
 {
     render_opts(g, w, &[])
 }
 
 /// Renders directed graph `g` into the writer `w` in DOT syntax.
 /// (Main entry point for the library.)
-pub fn render_opts<'a, N, E, G, W>(g: &'a G,
-                                   w: &mut W,
-                                   options: &[RenderOption])
-                                   -> io::Result<()>
-    where N: Clone + 'a,
-          E: Clone + 'a,
-          G: Labeller<'a, Node=N, Edge=E> + GraphWalk<'a, Node=N, Edge=E>,
-          W: Write
+pub fn render_opts<'a, N, E, G, W>(g: &'a G, w: &mut W, options: &[RenderOption]) -> io::Result<()>
+where
+    N: Clone + 'a,
+    E: Clone + 'a,
+    G: Labeller<'a, Node = N, Edge = E> + GraphWalk<'a, Node = N, Edge = E>,
+    W: Write,
 {
     writeln!(w, "digraph {} {{", g.graph_id().as_slice())?;
     for n in g.nodes().iter() {