//! * [DOT language](http://www.graphviz.org/doc/info/lang.html)
#![crate_name = "graphviz"]
-#![experimental]
+#![unstable]
#![staged_api]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(slicing_syntax)]
+#![allow(unknown_features)] #![feature(int_uint)]
+#![allow(unstable)]
use self::LabelText::*;
///
/// Passing an invalid string (containing spaces, brackets,
/// quotes, ...) will return an empty `Err` value.
- pub fn new<Name: IntoCow<'a, String, str>>(name: Name) -> Result<Id<'a>, ()> {
+ pub fn new<Name: IntoCow<'a, String, str>>(name: Name) -> Option<Id<'a>> {
let name = name.into_cow();
{
let mut chars = name.chars();
match chars.next() {
Some(c) if is_letter_or_underscore(c) => { ; },
- _ => return Err(())
+ _ => return None
}
if !chars.all(is_constituent) {
- return Err(());
+ return None
}
}
- return Ok(Id{ name: name });
+ return Some(Id{ name: name });
fn is_letter_or_underscore(c: char) -> bool {
in_range('a', c, 'z') || in_range('A', c, 'Z') || c == '_'
pub fn escape(&self) -> String {
match self {
&LabelStr(ref s) => s.escape_default(),
- &EscStr(ref s) => LabelText::escape_str(s.index(&FullRange)),
+ &EscStr(ref s) => LabelText::escape_str(&s[]),
}
}
let mut prefix = self.pre_escaped_content().into_owned();
let suffix = suffix.pre_escaped_content();
prefix.push_str(r"\n\n");
- prefix.push_str(suffix.index(&FullRange));
+ prefix.push_str(&suffix[]);
EscStr(prefix.into_cow())
}
}
impl<'a> Labeller<'a, Node, &'a Edge> for LabelledGraph {
fn graph_id(&'a self) -> Id<'a> {
- Id::new(self.name.index(&FullRange)).unwrap()
+ Id::new(&self.name[]).unwrap()
}
fn node_id(&'a self, n: &Node) -> Id<'a> {
id_name(n)
fn simple_id_construction() {
let id1 = Id::new("hello");
match id1 {
- Ok(_) => {;},
- Err(_) => panic!("'hello' is not a valid value for id anymore")
+ Some(_) => {;},
+ None => panic!("'hello' is not a valid value for id anymore")
}
}
fn badly_formatted_id() {
let id2 = Id::new("Weird { struct : ure } !!!");
match id2 {
- Ok(_) => panic!("graphviz id suddenly allows spaces, brackets and stuff"),
- Err(_) => {;}
+ Some(_) => panic!("graphviz id suddenly allows spaces, brackets and stuff"),
+ None => {;}
}
}
}