diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-01-21 09:14:39 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-21 09:14:39 -0800 |
| commit | 9227db398aa6ec4a538fc2d5a9d4f53e9ae7b9da (patch) | |
| tree | 0d7c55ee7a31fd538ecd591d6551fa43762d9583 /src/test | |
| parent | ad2c3e8dbc53eee30bbbcfa1a0927f58d5ad8536 (diff) | |
| parent | 00cddb068c4cb17a91cca646103e0fba8c0a8077 (diff) | |
| download | rust-9227db398aa6ec4a538fc2d5a9d4f53e9ae7b9da.tar.gz rust-9227db398aa6ec4a538fc2d5a9d4f53e9ae7b9da.zip | |
rollup merge of #21392: japaric/iter
closes #20953 closes #21361 --- In the future, we will likely derive these `impl`s via syntax extensions or using compiler magic (see #20617). For the time being we can use these manual `impl`s. r? @aturon cc @burntsushi @Kroisse
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/issue-20953.rs | 19 | ||||
| -rw-r--r-- | src/test/run-pass/issue-21361.rs | 19 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/run-pass/issue-20953.rs b/src/test/run-pass/issue-20953.rs new file mode 100644 index 00000000000..647302bbc93 --- /dev/null +++ b/src/test/run-pass/issue-20953.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let mut shrinker: Box<Iterator<Item=i32>> = Box::new(vec![1].into_iter()); + println!("{:?}", shrinker.next()); + for v in shrinker { assert!(false); } + + let mut shrinker: &mut Iterator<Item=i32> = &mut vec![1].into_iter(); + println!("{:?}", shrinker.next()); + for v in shrinker { assert!(false); } +} diff --git a/src/test/run-pass/issue-21361.rs b/src/test/run-pass/issue-21361.rs new file mode 100644 index 00000000000..bb20b3a3215 --- /dev/null +++ b/src/test/run-pass/issue-21361.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let v = vec![1, 2, 3]; + let boxed: Box<Iterator<Item=i32>> = Box::new(v.into_iter()); + assert_eq!(boxed.max(), Some(3)); + + let v = vec![1, 2, 3]; + let boxed: &mut Iterator<Item=i32> = &mut v.into_iter(); + assert_eq!(boxed.max(), Some(3)); +} |
