Update Examples
parent
5b67dd529b
commit
0ebe26c8ea
@ -910,7 +910,7 @@ fn main
|
||||
</td></tr></table>
|
||||
|
||||
#### for loops
|
||||
This subsection introduces the three ways of converting collections into iterators. For convenience, we combine them into a single example here. Note that Husht will provide three different prepositions for looping as syntactic sugar for the three methods of obtaining an iterator from the collection. The proposal below uses `in` as Rust does, `from` for borrowing, and `on` for borrowing mutably. We should also consider `in`, `&in`, and `&mut in`, as that might be more Rust-y.
|
||||
This subsection introduces the three ways of converting collections into iterators. For convenience, we combine them into a single example here. Note that in Husht you can select the mode of conversion by decorating the looping preposition `in`.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
@ -958,7 +958,7 @@ fn main() {
|
||||
fn main
|
||||
let mut names = vec!["Bob", "Frank", "Ferris"]
|
||||
|
||||
for name from names
|
||||
for name &in names
|
||||
match name
|
||||
&"Ferris" => println! "Rustacean alert!"
|
||||
_ => println! "Hello {}", name
|
||||
@ -967,7 +967,7 @@ fn main
|
||||
|
||||
|
||||
|
||||
for name on names
|
||||
for name &mut in names
|
||||
*name = match name
|
||||
&mut "Ferris" => "Rustacean alert!"
|
||||
_ => "Hello"
|
||||
|
Loading…
Reference in New Issue
Block a user