method List.iter
Lazy iterator over a snapshot of the list (D-2001): later changes to the list are not seen and the iterator holds no borrow, so it may be returned or stored.
Example:
fn main() io {
var xs = [1, 2, 3]
let it = xs.iter()
xs.push(4)
print("{it.count()} {xs.len()}")
}Вывод
3 4
pub(api) fn iter() -> iter<T>Сложность. O(n): the iterator works on a snapshot.
С версии. 1.0.0-beta
Возвращает
iter<T>
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/iter.oxl:814