diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-02-28 13:09:09 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-03-01 22:40:52 -0800 |
| commit | 58fd6ab90db3eb68c94695e1254a73e57bc44658 (patch) | |
| tree | 51078e799ec82df848205dce6f32a8f1c0c312f5 /src/libsyntax/util | |
| parent | df40aeccdbfcfb0cc7851c6df24f28fbeccfe046 (diff) | |
| download | rust-58fd6ab90db3eb68c94695e1254a73e57bc44658.tar.gz rust-58fd6ab90db3eb68c94695e1254a73e57bc44658.zip | |
libsyntax: Mechanically change `~[T]` to `Vec<T>`
Diffstat (limited to 'src/libsyntax/util')
| -rw-r--r-- | src/libsyntax/util/interner.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/util/parser_testing.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/util/small_vector.rs | 24 |
3 files changed, 22 insertions, 22 deletions
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 7b885df0317..7969cacb765 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -24,7 +24,7 @@ use std::rc::Rc; pub struct Interner<T> { priv map: RefCell<HashMap<T, Name>>, - priv vect: RefCell<~[T]>, + priv vect: RefCell<Vec<T> >, } // when traits can extend traits, we should extend index<Name,T> to get [] @@ -32,7 +32,7 @@ impl<T:Eq + Hash + Freeze + Clone + 'static> Interner<T> { pub fn new() -> Interner<T> { Interner { map: RefCell::new(HashMap::new()), - vect: RefCell::new(~[]), + vect: RefCell::new(Vec::new()), } } @@ -134,7 +134,7 @@ impl RcStr { // &str rather than RcStr, resulting in less allocation. pub struct StrInterner { priv map: RefCell<HashMap<RcStr, Name>>, - priv vect: RefCell<~[RcStr]>, + priv vect: RefCell<Vec<RcStr> >, } // when traits can extend traits, we should extend index<Name,T> to get [] @@ -142,7 +142,7 @@ impl StrInterner { pub fn new() -> StrInterner { StrInterner { map: RefCell::new(HashMap::new()), - vect: RefCell::new(~[]), + vect: RefCell::new(Vec::new()), } } diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index 8c7ad028a8e..36243350d21 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -17,20 +17,20 @@ use parse::token; // map a string to tts, using a made-up filename: return both the TokenTree's // and the ParseSess -pub fn string_to_tts_and_sess (source_str : ~str) -> (~[ast::TokenTree], @ParseSess) { +pub fn string_to_tts_and_sess (source_str : ~str) -> (Vec<ast::TokenTree> , @ParseSess) { let ps = new_parse_sess(); (filemap_to_tts(ps,string_to_filemap(ps,source_str,~"bogofile")),ps) } // map a string to tts, using a made-up filename: -pub fn string_to_tts(source_str : ~str) -> ~[ast::TokenTree] { +pub fn string_to_tts(source_str : ~str) -> Vec<ast::TokenTree> { let (tts,_) = string_to_tts_and_sess(source_str); tts } pub fn string_to_parser_and_sess(source_str: ~str) -> (Parser,@ParseSess) { let ps = new_parse_sess(); - (new_parser_from_source_str(ps,~[],~"bogofile",source_str),ps) + (new_parser_from_source_str(ps,Vec::new(),~"bogofile",source_str),ps) } // map string to parser (via tts) @@ -69,14 +69,14 @@ pub fn string_to_expr (source_str : ~str) -> @ast::Expr { // parse a string, return an item pub fn string_to_item (source_str : ~str) -> Option<@ast::Item> { with_error_checking_parse(source_str, |p| { - p.parse_item(~[]) + p.parse_item(Vec::new()) }) } // parse a string, return a stmt pub fn string_to_stmt(source_str : ~str) -> @ast::Stmt { with_error_checking_parse(source_str, |p| { - p.parse_stmt(~[]) + p.parse_stmt(Vec::new()) }) } @@ -87,7 +87,7 @@ pub fn string_to_pat(source_str : ~str) -> @ast::Pat { } // convert a vector of strings to a vector of ast::Ident's -pub fn strs_to_idents(ids: ~[&str]) -> ~[ast::Ident] { +pub fn strs_to_idents(ids: Vec<&str> ) -> Vec<ast::Ident> { ids.map(|u| token::str_to_ident(*u)) } diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index d6cc35a6f9d..22bf0f0a53f 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -14,7 +14,7 @@ use std::vec; pub enum SmallVector<T> { priv Zero, priv One(T), - priv Many(~[T]), + priv Many(Vec<T> ), } impl<T> Container for SmallVector<T> { @@ -46,7 +46,7 @@ impl<T> SmallVector<T> { One(v) } - pub fn many(vs: ~[T]) -> SmallVector<T> { + pub fn many(vs: Vec<T> ) -> SmallVector<T> { Many(vs) } @@ -56,7 +56,7 @@ impl<T> SmallVector<T> { One(..) => { let one = mem::replace(self, Zero); match one { - One(v1) => mem::replace(self, Many(~[v1, v])), + One(v1) => mem::replace(self, Many(vec!(v1, v))), _ => unreachable!() }; } @@ -142,7 +142,7 @@ mod test { assert_eq!(0, v.len()); assert_eq!(1, SmallVector::one(1).len()); - assert_eq!(5, SmallVector::many(~[1, 2, 3, 4, 5]).len()); + assert_eq!(5, SmallVector::many(vec!(1, 2, 3, 4, 5)).len()); } #[test] @@ -161,7 +161,7 @@ mod test { #[test] fn test_from_iterator() { - let v: SmallVector<int> = (~[1, 2, 3]).move_iter().collect(); + let v: SmallVector<int> = (vec!(1, 2, 3)).move_iter().collect(); assert_eq!(3, v.len()); assert_eq!(&1, v.get(0)); assert_eq!(&2, v.get(1)); @@ -171,14 +171,14 @@ mod test { #[test] fn test_move_iter() { let v = SmallVector::zero(); - let v: ~[int] = v.move_iter().collect(); - assert_eq!(~[], v); + let v: Vec<int> = v.move_iter().collect(); + assert_eq!(Vec::new(), v); let v = SmallVector::one(1); - assert_eq!(~[1], v.move_iter().collect()); + assert_eq!(vec!(1), v.move_iter().collect()); - let v = SmallVector::many(~[1, 2, 3]); - assert_eq!(~[1, 2, 3], v.move_iter().collect()); + let v = SmallVector::many(vec!(1, 2, 3)); + assert_eq!(vec!(1, 2, 3), v.move_iter().collect()); } #[test] @@ -190,12 +190,12 @@ mod test { #[test] #[should_fail] fn test_expect_one_many() { - SmallVector::many(~[1, 2]).expect_one(""); + SmallVector::many(vec!(1, 2)).expect_one(""); } #[test] fn test_expect_one_one() { assert_eq!(1, SmallVector::one(1).expect_one("")); - assert_eq!(1, SmallVector::many(~[1]).expect_one("")); + assert_eq!(1, SmallVector::many(vec!(1)).expect_one("")); } } |
