diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-10-23 08:42:21 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-10-30 08:54:30 -0700 |
| commit | 1d356624a1c03363be37886ffdad7dcf25ee81f6 (patch) | |
| tree | 4aef71be9e3f509b1bc8b4880e6894656e6404c4 /src/libregex | |
| parent | 18a3db6aa1ce9e66b0c9cb776588d56470c6078b (diff) | |
| download | rust-1d356624a1c03363be37886ffdad7dcf25ee81f6.tar.gz rust-1d356624a1c03363be37886ffdad7dcf25ee81f6.zip | |
collections: Enable IndexMut for some collections
This commit enables implementations of IndexMut for a number of collections, including Vec, RingBuf, SmallIntMap, TrieMap, TreeMap, and HashMap. At the same time this deprecates the `get_mut` methods on vectors in favor of using the indexing notation. cc #18424
Diffstat (limited to 'src/libregex')
| -rw-r--r-- | src/libregex/compile.rs | 6 | ||||
| -rw-r--r-- | src/libregex/parse.rs | 2 | ||||
| -rw-r--r-- | src/libregex/vm.rs | 10 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/libregex/compile.rs b/src/libregex/compile.rs index 53d2ea62a2a..2b82b620e39 100644 --- a/src/libregex/compile.rs +++ b/src/libregex/compile.rs @@ -157,7 +157,7 @@ impl<'r> Compiler<'r> { if cap >= len { self.names.grow(10 + cap - len, None) } - *self.names.get_mut(cap) = name; + self.names[cap] = name; self.push(Save(2 * cap)); self.compile(*x); @@ -243,7 +243,7 @@ impl<'r> Compiler<'r> { /// `panic!` is called. #[inline] fn set_split(&mut self, i: InstIdx, pc1: InstIdx, pc2: InstIdx) { - let split = self.insts.get_mut(i); + let split = &mut self.insts[i]; match *split { Split(_, _) => *split = Split(pc1, pc2), _ => panic!("BUG: Invalid split index."), @@ -263,7 +263,7 @@ impl<'r> Compiler<'r> { /// `panic!` is called. #[inline] fn set_jump(&mut self, i: InstIdx, pc: InstIdx) { - let jmp = self.insts.get_mut(i); + let jmp = &mut self.insts[i]; match *jmp { Jump(_) => *jmp = Jump(pc), _ => panic!("BUG: Invalid jump index."), diff --git a/src/libregex/parse.rs b/src/libregex/parse.rs index d71cc9cb511..3115161682f 100644 --- a/src/libregex/parse.rs +++ b/src/libregex/parse.rs @@ -978,7 +978,7 @@ fn combine_ranges(unordered: Vec<(char, char)>) -> Vec<(char, char)> { } match which { None => ordered.push((us, ue)), - Some(i) => *ordered.get_mut(i) = (us, ue), + Some(i) => ordered[i] = (us, ue), } } ordered.sort(); diff --git a/src/libregex/vm.rs b/src/libregex/vm.rs index 0a4dca9125a..ce06828e764 100644 --- a/src/libregex/vm.rs +++ b/src/libregex/vm.rs @@ -461,13 +461,13 @@ impl Threads { } fn add(&mut self, pc: uint, groups: &[Option<uint>], empty: bool) { - let t = self.queue.get_mut(self.size); + let t = &mut self.queue[self.size]; t.pc = pc; match (empty, self.which) { (_, Exists) | (true, _) => {}, (false, Location) => { - *t.groups.get_mut(0) = groups[0]; - *t.groups.get_mut(1) = groups[1]; + t.groups[0] = groups[0]; + t.groups[1] = groups[1]; } (false, Submatches) => { for (slot, val) in t.groups.iter_mut().zip(groups.iter()) { @@ -475,7 +475,7 @@ impl Threads { } } } - *self.sparse.get_mut(pc) = self.size; + self.sparse[pc] = self.size; self.size += 1; } @@ -497,7 +497,7 @@ impl Threads { #[inline] fn groups<'r>(&'r mut self, i: uint) -> &'r mut [Option<uint>] { - self.queue.get_mut(i).groups.as_mut_slice() + self.queue[i].groups.as_mut_slice() } } |
