You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rust currently provides three approaches to performing some kind of iterative activity. They are: `loop`, `while` and `for`. Each approach has its own set of uses.
4
+
<!-- Rust currently provides three approaches to performing some kind of iterative activity. They are: `loop`, `while` and `for`. Each approach has its own set of uses. -->
The infinite `loop` is the simplest form of loop available in Rust. Using the keyword `loop`, Rust provides a way to loop indefinitely until some terminating statement is reached. Rust's infinite `loop`s look like this:
10
+
<!-- The infinite `loop` is the simplest form of loop available in Rust. Using the keyword `loop`, Rust provides a way to loop indefinitely until some terminating statement is reached. Rust's infinite `loop`s look like this: -->
In this case, we can write the loop in a better way with `break`:
204
+
<!-- In this case, we can write the loop in a better way with `break`: -->
205
+
この例では、 `break` を使ってループを記述した方が良いでしょう:
167
206
168
207
```rust
169
208
letmutx=5;
@@ -177,10 +216,14 @@ loop {
177
216
}
178
217
```
179
218
180
-
We now loop forever with `loop` and use `break` to break out early. Issuing an explicit `return` statement will also serve to terminate the loop early.
219
+
<!-- We now loop forever with `loop` and use `break` to break out early. Issuing an explicit `return` statement will also serve to terminate the loop early. -->
220
+
ここでは `loop` による永久ループと `break` による早期脱出を使っています。
221
+
明示的な `return` 文の発行でもループの早期終了になります。
181
222
182
-
`continue` is similar, but instead of ending the loop, goes to the next
183
-
iteration. This will only print the odd numbers:
223
+
<!-- `continue` is similar, but instead of ending the loop, goes to the next -->
224
+
<!-- iteration. This will only print the odd numbers: -->
225
+
`continue` も似ていますが、ループを終了させるのではなく、次の反復へと進めます。
226
+
これは奇数だけを表示するでしょう:
184
227
185
228
```rust
186
229
forxin0..10 {
@@ -190,21 +233,28 @@ for x in 0..10 {
190
233
}
191
234
```
192
235
193
-
## Loop labels
194
-
195
-
You may also encounter situations where you have nested loops and need to
196
-
specify which one your `break` or `continue` statement is for. Like most
197
-
other languages, by default a `break` or `continue` will apply to innermost
198
-
loop. In a situation where you would like to a `break` or `continue` for one
199
-
of the outer loops, you can use labels to specify which loop the `break` or
200
-
`continue` statement applies to. This will only print when both `x` and `y` are
201
-
odd:
236
+
<!-- ## Loop labels -->
237
+
## ループラベル
238
+
239
+
<!-- You may also encounter situations where you have nested loops and need to -->
240
+
<!-- specify which one your `break` or `continue` statement is for. Like most -->
241
+
<!-- other languages, by default a `break` or `continue` will apply to innermost -->
242
+
<!-- loop. In a situation where you would like to a `break` or `continue` for one -->
243
+
<!-- of the outer loops, you can use labels to specify which loop the `break` or -->
244
+
<!-- `continue` statement applies to. This will only print when both `x` and `y` are -->
0 commit comments