xref: /third_party/rust/crates/pin-utils/tests/stack_pin.rs
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/rust/crates/pin-utils/tests/
160b26363Sopenharmony_ci#![forbid(unsafe_code)] // pin_mut! is completely safe.
260b26363Sopenharmony_ci
360b26363Sopenharmony_ciuse pin_utils::pin_mut;
460b26363Sopenharmony_ciuse core::pin::Pin;
560b26363Sopenharmony_ci
660b26363Sopenharmony_ci#[test]
760b26363Sopenharmony_cifn stack_pin() {
860b26363Sopenharmony_ci    struct Foo {}
960b26363Sopenharmony_ci    let foo = Foo {};
1060b26363Sopenharmony_ci    pin_mut!(foo);
1160b26363Sopenharmony_ci    let _: Pin<&mut Foo> = foo;
1260b26363Sopenharmony_ci
1360b26363Sopenharmony_ci    let bar = Foo {};
1460b26363Sopenharmony_ci    let baz = Foo {};
1560b26363Sopenharmony_ci    pin_mut!(
1660b26363Sopenharmony_ci        bar,
1760b26363Sopenharmony_ci        baz,
1860b26363Sopenharmony_ci    );
1960b26363Sopenharmony_ci    let _: Pin<&mut Foo> = bar;
2060b26363Sopenharmony_ci    let _: Pin<&mut Foo> = baz;
2160b26363Sopenharmony_ci}
22

Indexes created Thu Nov 07 10:32:03 CST 2024