Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

50.2.1Loop exercise

3
4
7
8
11
12
15
16
19
20
23
24
27
28
31
()

50.2.2Checker

Here are the two for loops needed to draw the grid:


 
X 
 X 
X X 
 X X 
X X X 
 X X X 
X X X X 
 X X X X 
X X X X X 
 X X X X X 
X X X X X X 
 X X X X X X 
X X X X X X X 
 X X X X X X X 
X X X X X X X X 
 X X X X X X X X 
X X X X X X X X X 
 X X X X X X X X X 
()

50.2.3Multiple search in a string

We define the letters and the string:

We loop on each letter to search for, and test the result of find() using if let Some(...):

Found c at index 2.
Found a at index 0.
Found h at index 7.
()

50.2.4Iterating over results

We define the string variable:

We store the iterator returned by lines():

Couldn't automatically determine type of variable `lines`.
Please give it an explicit type.

We use the while let construct to iterate over all results until the end (None value):