]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/subst.rs
std: Rename Show/String to Debug/Display
[rust.git] / src / librustc / middle / subst.rs
index d019af50a7dada9d9032cbd3b9e82e8e8b665628..83bb9a351e400ed0c2d29250f9bec4834ff14881 100644 (file)
@@ -19,7 +19,7 @@
 
 use std::fmt;
 use std::slice::Iter;
-use std::vec::Vec;
+use std::vec::{Vec, IntoIter};
 use syntax::codemap::{Span, DUMMY_SP};
 
 ///////////////////////////////////////////////////////////////////////////
@@ -238,7 +238,7 @@ pub struct SeparateVecsPerParamSpace<T> {
     pub fns: Vec<T>,
 }
 
-impl<T:fmt::Show> fmt::Show for VecPerParamSpace<T> {
+impl<T: fmt::Debug> fmt::Debug for VecPerParamSpace<T> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         try!(write!(fmt, "VecPerParamSpace {{"));
         for space in ParamSpace::all().iter() {
@@ -313,6 +313,17 @@ pub fn push(&mut self, space: ParamSpace, value: T) {
         self.content.insert(limit, value);
     }
 
+    /// Appends `values` to the vector associated with `space`.
+    ///
+    /// Unlike the `extend` method in `Vec`, this should not be assumed
+    /// to be a cheap operation (even when amortized over many calls).
+    pub fn extend<I:Iterator<Item=T>>(&mut self, space: ParamSpace, mut values: I) {
+        // This could be made more efficient, obviously.
+        for item in values {
+            self.push(space, item);
+        }
+    }
+
     pub fn pop(&mut self, space: ParamSpace) -> Option<T> {
         let (start, limit) = self.limits(space);
         if start == limit {
@@ -386,6 +397,10 @@ pub fn iter<'a>(&'a self) -> Iter<'a,T> {
         self.content.iter()
     }
 
+    pub fn into_iter(self) -> IntoIter<T> {
+        self.content.into_iter()
+    }
+
     pub fn iter_enumerated<'a>(&'a self) -> EnumeratedItems<'a,T> {
         EnumeratedItems::new(self)
     }
@@ -394,7 +409,7 @@ pub fn as_slice(&self) -> &[T] {
         self.content.as_slice()
     }
 
-    pub fn to_vec(self) -> Vec<T> {
+    pub fn into_vec(self) -> Vec<T> {
         self.content
     }