extract_function does not move locals defined outside of loops

This commit is contained in:
Lukas Wirth 2021-08-04 20:00:45 +02:00
parent f55441f7ed
commit 01413dd7d4
2 changed files with 141 additions and 14 deletions

View file

@ -17,6 +17,7 @@
//! deref_mut: deref
//! index: sized
//! fn:
//! try:
//! pin:
//! future: pin
//! option:
@ -266,6 +267,28 @@ pub mod ops {
}
pub use self::function::{Fn, FnMut, FnOnce};
// endregion:fn
// region:try
mod try_ {
pub enum ControlFlow<B, C = ()> {
Continue(C),
Break(B),
}
pub trait FromResidual<R = Self::Residual> {
#[lang = "from_residual"]
fn from_residual(residual: R) -> Self;
}
#[lang = "try"]
pub trait Try: FromResidual<Self::Residual> {
type Output;
type Residual;
#[lang = "from_output"]
fn from_output(output: Self::Output) -> Self;
#[lang = "branch"]
fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
}
}
pub use self::try_::{ControlFlow, FromResidual, Try};
// endregion:try
}
// region:eq