]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/graph.rs
std: Rename Show/String to Debug/Display
[rust.git] / src / librustc / middle / graph.rs
index da00d737b473e785aa807d5ecf6fe8155441b522..affeef330c4541cbafeae7e255fcb449fc3407b6 100644 (file)
@@ -32,7 +32,7 @@
 
 #![allow(dead_code)] // still WIP
 
-use std::fmt::{Formatter, Error, Show};
+use std::fmt::{Formatter, Error, Debug};
 use std::uint;
 use std::collections::BitvSet;
 
@@ -53,26 +53,26 @@ pub struct Edge<E> {
     pub data: E,
 }
 
-impl<E: Show> Show for Edge<E> {
+impl<E: Debug> Debug for Edge<E> {
     fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
-        write!(f, "Edge {{ next_edge: [{}, {}], source: {}, target: {}, data: {} }}",
+        write!(f, "Edge {{ next_edge: [{:?}, {:?}], source: {:?}, target: {:?}, data: {:?} }}",
                self.next_edge[0], self.next_edge[1], self.source,
                self.target, self.data)
     }
 }
 
-#[deriving(Clone, Copy, PartialEq, Show)]
+#[derive(Clone, Copy, PartialEq, Show)]
 pub struct NodeIndex(pub uint);
 #[allow(non_upper_case_globals)]
 pub const InvalidNodeIndex: NodeIndex = NodeIndex(uint::MAX);
 
-#[deriving(Copy, PartialEq, Show)]
+#[derive(Copy, PartialEq, Show)]
 pub struct EdgeIndex(pub uint);
 #[allow(non_upper_case_globals)]
 pub const InvalidEdgeIndex: EdgeIndex = EdgeIndex(uint::MAX);
 
 // Use a private field here to guarantee no more instances are created:
-#[deriving(Copy, Show)]
+#[derive(Copy, Show)]
 pub struct Direction { repr: uint }
 #[allow(non_upper_case_globals)]
 pub const Outgoing: Direction = Direction { repr: 0 };
@@ -305,7 +305,9 @@ pub struct DepthFirstTraversal<'g, N:'g, E:'g> {
     visited: BitvSet
 }
 
-impl<'g, N, E> Iterator<&'g N> for DepthFirstTraversal<'g, N, E> {
+impl<'g, N, E> Iterator for DepthFirstTraversal<'g, N, E> {
+    type Item = &'g N;
+
     fn next(&mut self) -> Option<&'g N> {
         while let Some(idx) = self.stack.pop() {
             if !self.visited.insert(idx.node_id()) {
@@ -351,7 +353,7 @@ pub fn target(&self) -> NodeIndex {
 #[cfg(test)]
 mod test {
     use middle::graph::*;
-    use std::fmt::Show;
+    use std::fmt::Debug;
 
     type TestNode = Node<&'static str>;
     type TestEdge = Edge<&'static str>;
@@ -406,7 +408,7 @@ fn each_edge() {
         });
     }
 
-    fn test_adjacent_edges<N:PartialEq+Show,E:PartialEq+Show>(graph: &Graph<N,E>,
+    fn test_adjacent_edges<N:PartialEq+Debug,E:PartialEq+Debug>(graph: &Graph<N,E>,
                                       start_index: NodeIndex,
                                       start_data: N,
                                       expected_incoming: &[(E,N)],
@@ -417,7 +419,7 @@ fn test_adjacent_edges<N:PartialEq+Show,E:PartialEq+Show>(graph: &Graph<N,E>,
         graph.each_incoming_edge(start_index, |edge_index, edge| {
             assert!(graph.edge_data(edge_index) == &edge.data);
             assert!(counter < expected_incoming.len());
-            debug!("counter={} expected={} edge_index={} edge={}",
+            debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}",
                    counter, expected_incoming[counter], edge_index, edge);
             match expected_incoming[counter] {
                 (ref e, ref n) => {
@@ -435,7 +437,7 @@ fn test_adjacent_edges<N:PartialEq+Show,E:PartialEq+Show>(graph: &Graph<N,E>,
         graph.each_outgoing_edge(start_index, |edge_index, edge| {
             assert!(graph.edge_data(edge_index) == &edge.data);
             assert!(counter < expected_outgoing.len());
-            debug!("counter={} expected={} edge_index={} edge={}",
+            debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}",
                    counter, expected_outgoing[counter], edge_index, edge);
             match expected_outgoing[counter] {
                 (ref e, ref n) => {