libstd: Implement some convenience methods on vectors

This commit is contained in:
Patrick Walton
2014-02-18 21:36:51 -08:00
parent f8893ed5d9
commit 03b791095d
5 changed files with 223 additions and 11 deletions

View File

@@ -101,6 +101,7 @@ use to_str::ToStr;
use from_str::FromStr;
use vec;
use vec::{OwnedVector, OwnedCloneableVector, ImmutableVector, MutableVector};
use vec_ng::Vec;
use default::Default;
use to_bytes::{IterBytes, Cb};
use unstable::raw::Repr;
@@ -222,6 +223,18 @@ impl<'a, S: Str> StrVector for &'a [S] {
}
}
impl<'a, S: Str> StrVector for Vec<S> {
#[inline]
fn concat(&self) -> ~str {
self.as_slice().concat()
}
#[inline]
fn connect(&self, sep: &str) -> ~str {
self.as_slice().connect(sep)
}
}
/// Something that can be used to compare against a character
pub trait CharEq {
/// Determine if the splitter should split at the given character