X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2Flibgraphviz%2Flib.rs;h=c1bd188d3a286ef9b4ca1a84ecf103595f12ed18;hb=92a42be040f16457c75b14472f3b63228e7cf6fa;hp=b82b7d122b3ce8205c760602202243faed391eeb;hpb=b039eaaf8ae75fd8307e115bc1e75e5868f78fbc;p=rustc.git diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index b82b7d122b..c1bd188d3a 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -47,7 +47,7 @@ //! which is cyclic. //! //! ```rust -//! #![feature(rustc_private, core, into_cow)] +//! #![feature(rustc_private, into_cow)] //! //! use std::borrow::IntoCow; //! use std::io::Write; @@ -150,9 +150,8 @@ //! entity `&sube`). //! //! ```rust -//! #![feature(rustc_private, core, into_cow)] +//! #![feature(rustc_private)] //! -//! use std::borrow::IntoCow; //! use std::io::Write; //! use graphviz as dot; //! @@ -174,10 +173,10 @@ //! dot::Id::new(format!("N{}", n)).unwrap() //! } //! fn node_label<'b>(&'b self, n: &Nd) -> dot::LabelText<'b> { -//! dot::LabelText::LabelStr(self.nodes[*n].as_slice().into_cow()) +//! dot::LabelText::LabelStr(self.nodes[*n].into()) //! } //! fn edge_label<'b>(&'b self, _: &Ed) -> dot::LabelText<'b> { -//! dot::LabelText::LabelStr("⊆".into_cow()) +//! dot::LabelText::LabelStr("⊆".into()) //! } //! } //! @@ -209,9 +208,8 @@ //! Hasse-diagram for the subsets of the set `{x, y}`. //! //! ```rust -//! #![feature(rustc_private, core, into_cow)] +//! #![feature(rustc_private)] //! -//! use std::borrow::IntoCow; //! use std::io::Write; //! use graphviz as dot; //! @@ -234,10 +232,10 @@ //! } //! fn node_label<'b>(&'b self, n: &Nd<'b>) -> dot::LabelText<'b> { //! let &(i, _) = n; -//! dot::LabelText::LabelStr(self.nodes[i].into_cow()) +//! dot::LabelText::LabelStr(self.nodes[i].into()) //! } //! fn edge_label<'b>(&'b self, _: &Ed<'b>) -> dot::LabelText<'b> { -//! dot::LabelText::LabelStr("⊆".into_cow()) +//! dot::LabelText::LabelStr("⊆".into()) //! } //! } //! @@ -278,12 +276,13 @@ #![crate_name = "graphviz"] #![unstable(feature = "rustc_private", issue = "27812")] #![feature(staged_api)] -#![staged_api] +#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] + html_root_url = "https://doc.rust-lang.org/nightly/", + test(attr(allow(unused_variables), deny(warnings))))] #![feature(into_cow)] #![feature(str_escape)] @@ -417,10 +416,10 @@ impl<'a> Id<'a> { _ => return Err(()), } if !chars.all(is_constituent) { - return Err(()) + return Err(()); } } - return Ok(Id{ name: name }); + return Ok(Id { name: name }); fn is_letter_or_underscore(c: char) -> bool { in_range('a', c, 'z') || in_range('A', c, 'Z') || c == '_' @@ -497,11 +496,10 @@ pub trait Labeller<'a,N,E> { /// 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("&", "&") - .replace("\"", """) - .replace("<", "<") - .replace(">", ">") + s.replace("&", "&") + .replace("\"", """) + .replace("<", "<") + .replace(">", ">") } impl<'a> LabelText<'a> { @@ -524,9 +522,11 @@ impl<'a> LabelText<'a> { // not escaping \\, since Graphviz escString needs to // interpret backslashes; see EscStr above. '\\' => f(c), - _ => for c in c.escape_default() { - f(c) - }, + _ => { + for c in c.escape_default() { + f(c) + } + } } } fn escape_str(s: &str) -> String { @@ -554,11 +554,13 @@ impl<'a> LabelText<'a> { fn pre_escaped_content(self) -> Cow<'a, str> { match self { EscStr(s) => s, - LabelStr(s) => if s.contains('\\') { - (&*s).escape_default().into_cow() - } else { - s - }, + LabelStr(s) => { + if s.contains('\\') { + (&*s).escape_default().into_cow() + } else { + s + } + } HtmlStr(s) => s, } } @@ -739,7 +741,12 @@ mod tests { } fn edge(from: usize, to: usize, label: &'static str, style: Style) -> Edge { - Edge { from: from, to: to, label: label, style: style } + Edge { + from: from, + to: to, + label: label, + style: style, + } } struct LabelledGraph { @@ -1010,7 +1017,7 @@ r#"digraph single_cyclic_node { #[test] fn hasse_diagram() { - let labels = AllNodesLabelled(vec!("{x,y}", "{x}", "{y}", "{}")); + let labels = AllNodesLabelled(vec!["{x,y}", "{x}", "{y}", "{}"]); let r = test_input(LabelledGraph::new("hasse_diagram", labels, vec![edge(0, 1, "", Style::None), @@ -1034,7 +1041,7 @@ r#"digraph hasse_diagram { #[test] fn left_aligned_text() { - let labels = AllNodesLabelled(vec!( + let labels = AllNodesLabelled(vec![ "if test {\ \\l branch1\ \\l} else {\ @@ -1044,7 +1051,7 @@ r#"digraph hasse_diagram { \\l", "branch1", "branch2", - "afterward")); + "afterward"]); let mut writer = Vec::new();