1
Fork 0

librustc: Disallow multiple patterns from appearing in a "let" declaration.

You can still initialize multiple variables at once with "let (x, y) = (1, 2)".
This commit is contained in:
Patrick Walton 2013-06-04 21:43:41 -07:00
parent 16086ecff7
commit 8114d0e950
80 changed files with 425 additions and 263 deletions

View file

@ -749,7 +749,7 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
pub fn dedup<T:Eq>(v: &mut ~[T]) {
unsafe {
if v.len() < 1 { return; }
let mut last_written = 0, next_to_read = 1;
let mut (last_written, next_to_read) = (0, 1);
do as_const_buf(*v) |p, ln| {
// We have a mutable reference to v, so we can make arbitrary
// changes. (cf. push and pop)
@ -1365,7 +1365,7 @@ pub fn bsearch_elem<T:TotalOrd>(v: &[T], x: &T) -> Option<uint> {
* Convert a vector of pairs into a pair of vectors, by reference. As unzip().
*/
pub fn unzip_slice<T:Copy,U:Copy>(v: &[(T, U)]) -> (~[T], ~[U]) {
let mut ts = ~[], us = ~[];
let mut (ts, us) = (~[], ~[]);
for each(v) |p| {
let (t, u) = *p;
ts.push(t);
@ -1383,7 +1383,7 @@ pub fn unzip_slice<T:Copy,U:Copy>(v: &[(T, U)]) -> (~[T], ~[U]) {
* of the i-th tuple of the input vector.
*/
pub fn unzip<T,U>(v: ~[(T, U)]) -> (~[T], ~[U]) {
let mut ts = ~[], us = ~[];
let mut (ts, us) = (~[], ~[]);
do consume(v) |_i, p| {
let (t, u) = p;
ts.push(t);