W3cubDocs

/Rust

Error code E0268

A loop keyword (break or continue) was used outside of a loop.

Erroneous code example:

#![allow(unused)]
fn main() {
fn some_func() {
    break; // error: `break` outside of a loop
}
}

Without a loop to break out of or continue in, no sensible action can be taken. Please verify that you are using break and continue only in loops. Example:

#![allow(unused)]
fn main() {
fn some_func() {
    for _ in 0..10 {
        break; // ok!
    }
}
}

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/error_codes/E0268.html