//! which is cyclic.
//!
//! ```rust
-//! #![feature(rustc_private, core, into_cow)]
+//! #![feature(rustc_private, into_cow)]
//!
//! use std::borrow::IntoCow;
//! use std::io::Write;
//! entity `&sube`).
//!
//! ```rust
-//! #![feature(rustc_private, core, into_cow)]
+//! #![feature(rustc_private)]
//!
-//! use std::borrow::IntoCow;
//! use std::io::Write;
//! use graphviz as dot;
//!
//! 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())
//! }
//! }
//!
//! 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;
//!
//! }
//! 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())
//! }
//! }
//!
#![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)]
_ => 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 == '_'
/// 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> {
// 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 {
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,
}
}
}
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 {
#[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),
#[test]
fn left_aligned_text() {
- let labels = AllNodesLabelled(vec!(
+ let labels = AllNodesLabelled(vec![
"if test {\
\\l branch1\
\\l} else {\
\\l",
"branch1",
"branch2",
- "afterward"));
+ "afterward"]);
let mut writer = Vec::new();