Skip to content

Instantly share code, notes, and snippets.

@vijairaj
Forked from rust-play/playground.rs
Created December 11, 2018 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijairaj/74392a56b5e266404c38dc1b9739b433 to your computer and use it in GitHub Desktop.
Save vijairaj/74392a56b5e266404c38dc1b9739b433 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn main() {
let n = 0;
let val = loop {
if n == 0 {
break (1, "done");
}
};
println!("val: {:?}", val)
}
@vijairaj
Copy link
Author

if n != 0 makes it an infinite loop, compiler validates if all paths return the same data type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment