Skip to content

Instantly share code, notes, and snippets.

@Centril
Created June 17, 2018 01:14
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 Centril/baeba93ba0d5bf98d45d80e621bbdd46 to your computer and use it in GitHub Desktop.
Save Centril/baeba93ba0d5bf98d45d80e621bbdd46 to your computer and use it in GitHub Desktop.
for/while/while let .. else
// while P { B_1 } else { B_2 } */
// ==>
/*
if P {
B_1;
while P {
B_1
}
} else {
B_2
}
*/
// while let PAT = E { B_1 } else { B_2 } */
// ==>
/*
if let PAT = E {
B_1;
loop {
if let PAT = E {
B_1
} else {
break;
}
}
} else {
B_2
}
*/
// for PAT in E { B_1 } else { B_2 } */
// ==>
/*
{
let mut iter = E.into_iter();
while let Some(PAT) = iter.next() {
B_1
} else {
B_2
}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment