]> git.lizzy.rs Git - rust.git/blobdiff - src/libgraphviz/lib.rs
std: Rename Show/String to Debug/Display
[rust.git] / src / libgraphviz / lib.rs
index 21a8ba03454f53defd8c5afa85ea41274504de95..0ed32b7bf4f327647378dfe5ec4f5265b23c6b74 100644 (file)
 //! * [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::*;
 
@@ -356,19 +358,19 @@ impl<'a> Id<'a> {
     ///
     /// 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 == '_'
@@ -453,7 +455,7 @@ fn escape_str(s: &str) -> String {
     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[]),
         }
     }
 
@@ -482,7 +484,7 @@ pub fn suffix_line(self, suffix: LabelText) -> LabelText<'static> {
         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())
     }
 }
@@ -676,7 +678,7 @@ fn id_name<'a>(n: &Node) -> Id<'a> {
 
     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)
@@ -872,8 +874,8 @@ fn left_aligned_text() {
     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")
         }
     }
 
@@ -881,8 +883,8 @@ fn simple_id_construction() {
     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 => {;}
         }
     }
 }