mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
auto merge of #8030 : thestinger/rust/iterator, r=huonw
This commit is contained in:
commit
0012b5008b
@ -108,12 +108,14 @@ impl Iterator<int> for ZeroStream {
|
||||
## Container iterators
|
||||
|
||||
Containers implement iteration over the contained elements by returning an
|
||||
iterator object. For example, vector slices have four iterators available:
|
||||
iterator object. For example, vector slices several iterators available:
|
||||
|
||||
* `vector.iter()`, for immutable references to the elements
|
||||
* `vector.mut_iter()`, for mutable references to the elements
|
||||
* `vector.rev_iter()`, for immutable references to the elements in reverse order
|
||||
* `vector.mut_rev_iter()`, for mutable references to the elements in reverse order
|
||||
* `iter()` and `rev_iter()`, for immutable references to the elements
|
||||
* `mut_iter()` and `mut_rev_iter()`, for mutable references to the elements
|
||||
* `consume_iter()` and `consume_rev_iter`, to move the elements out by-value
|
||||
|
||||
A typical mutable container will implement at least `iter()`, `mut_iter()` and
|
||||
`consume_iter()` along with the reverse variants if it maintains an order.
|
||||
|
||||
### Freezing
|
||||
|
||||
|
@ -79,7 +79,6 @@ pub enum lint {
|
||||
non_camel_case_types,
|
||||
non_uppercase_statics,
|
||||
type_limits,
|
||||
default_methods,
|
||||
unused_unsafe,
|
||||
|
||||
managed_heap_memory,
|
||||
@ -222,13 +221,6 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
|
||||
default: warn
|
||||
}),
|
||||
|
||||
("default_methods",
|
||||
LintSpec {
|
||||
lint: default_methods,
|
||||
desc: "allow default methods",
|
||||
default: allow
|
||||
}),
|
||||
|
||||
("unused_unsafe",
|
||||
LintSpec {
|
||||
lint: unused_unsafe,
|
||||
@ -690,23 +682,6 @@ fn lint_type_limits() -> visit::vt<@mut Context> {
|
||||
})
|
||||
}
|
||||
|
||||
fn check_item_default_methods(cx: &Context, item: &ast::item) {
|
||||
match item.node {
|
||||
ast::item_trait(_, _, ref methods) => {
|
||||
for methods.iter().advance |method| {
|
||||
match *method {
|
||||
ast::required(*) => {}
|
||||
ast::provided(*) => {
|
||||
cx.span_lint(default_methods, item.span,
|
||||
"default methods are experimental");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_item_ctypes(cx: &Context, it: &ast::item) {
|
||||
fn check_ty(cx: &Context, ty: &ast::Ty) {
|
||||
match ty.node {
|
||||
@ -1143,7 +1118,6 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::Crate) {
|
||||
check_item_ctypes(cx, it);
|
||||
check_item_non_camel_case_types(cx, it);
|
||||
check_item_non_uppercase_statics(cx, it);
|
||||
check_item_default_methods(cx, it);
|
||||
check_item_heap(cx, it);
|
||||
|
||||
cx.process(Item(it));
|
||||
|
@ -21,7 +21,6 @@ and `Eq` to overload the `==` and `!=` operators.
|
||||
*/
|
||||
|
||||
#[allow(missing_doc)];
|
||||
#[allow(default_methods)]; // NOTE: Remove when allowed in stage0
|
||||
|
||||
/**
|
||||
* Trait for values that can be compared for equality and inequality.
|
||||
|
@ -17,8 +17,6 @@ implementing the `Iterator` trait.
|
||||
|
||||
*/
|
||||
|
||||
#[allow(default_methods)]; // still off by default in stage0
|
||||
|
||||
use cmp;
|
||||
use iter::Times;
|
||||
use num::{Zero, One};
|
||||
|
@ -152,8 +152,6 @@ cleanup_task(cleanup_args *args) {
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" CDECL void upcall_exchange_free(void *ptr);
|
||||
|
||||
// This runs on the Rust stack
|
||||
void task_start_wrapper(spawn_args *a)
|
||||
{
|
||||
|
@ -1,7 +0,0 @@
|
||||
#[forbid(default_methods)];
|
||||
|
||||
trait Foo { //~ ERROR default methods are experimental
|
||||
fn bar(&self) { println("hi"); }
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -10,8 +10,6 @@
|
||||
|
||||
// compile-flags:-Z debug-info
|
||||
|
||||
#[allow(default_methods)];
|
||||
|
||||
pub trait TraitWithDefaultMethod {
|
||||
pub fn method(self) {
|
||||
()
|
||||
@ -24,4 +22,4 @@ impl TraitWithDefaultMethod for MyStruct { }
|
||||
|
||||
fn main() {
|
||||
MyStruct.method();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user