为什么固定的未来实现取消固定?

问题描述 投票:0回答:0
fn test<T: Unpin>(t: T) {

}

fn main() {
    let a = 1;
    let b = async {
        1
    };
    test(b) // the trait `Unpin` is not implemented for `[async block]`
}

Future 不是 Unpin,那么为什么固定它(pin_mut、Box::pin 等,用 Pin<..> 包装它)使其实现 Unpin?

rust rust-futures rust-pin
© www.soinside.com 2019 - 2024. All rights reserved.