From 69ef14eca9b6dba604d61967a249909e9348067b Mon Sep 17 00:00:00 2001 From: Pedro Larroy Date: Tue, 13 Jan 2015 23:49:30 +0100 Subject: [PATCH 1/2] RFC add foreach to iterators --- text/0000-foreach.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 text/0000-foreach.md diff --git a/text/0000-foreach.md b/text/0000-foreach.md new file mode 100644 index 00000000000..f46074599ae --- /dev/null +++ b/text/0000-foreach.md @@ -0,0 +1,37 @@ +- Start Date: 2015-13-01 +- RFC PR: (leave this empty) +- Rust Issue: (leave this empty) + +# Summary + +This is a proposal to add .foreach to iterators. + +# Motivation + +After a chain of transformations on an iterator it might be desirable to have a side effecting +operation that consumes the iterator. Adding .foreach to iterators is proposed, which is a common +idiom in other languages for performing this operation. While the same effect can be achieved with a +for loop, in general is considered that flat is better than nested and leads to more readable code. + +# Detailed design + +The design is simple, just syntacting suggar around a loop that consumes the iterator as seen in +this PR. + +https://github.com/rust-lang/rust/pull/21098 + +# Drawbacks + + +# Alternatives + + +# Unresolved questions + +It has also been discussed in reddit and in the forum: + + +http://www.reddit.com/r/rust/comments/2s5jjs/does_having_foreach_implemented_for_iterators/ + +http://discuss.rust-lang.org/t/add-foreach-method-to-iterators-for-side-effects/1312/3 + From 4637e43ca5e823902e7006ddacf055f93adb9c1c Mon Sep 17 00:00:00 2001 From: Pedro Larroy Date: Wed, 14 Jan 2015 10:13:41 +0100 Subject: [PATCH 2/2] Fix typo --- text/0000-foreach.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-foreach.md b/text/0000-foreach.md index f46074599ae..cc31d24a434 100644 --- a/text/0000-foreach.md +++ b/text/0000-foreach.md @@ -15,7 +15,7 @@ for loop, in general is considered that flat is better than nested and leads to # Detailed design -The design is simple, just syntacting suggar around a loop that consumes the iterator as seen in +The design is simple, just syntactic suggar around a loop that consumes the iterator as seen in this PR. https://github.com/rust-lang/rust/pull/21098