| Crates.io | droppable-pin |
| lib.rs | droppable-pin |
| version | 0.1.1 |
| created_at | 2025-10-18 17:37:31.160433+00 |
| updated_at | 2025-10-20 11:39:18.851894+00 |
| description | The eponoymous `droppable_pin!` macro around a given `let var = pin!()` declaration allows invoking `pin_drop!` and `pin_set!` on the given `var`, which have in turn been designed to avoid silly borrow-checking errors. |
| homepage | |
| repository | https://github.com/danielhenrymantilla/droppable-pin.rs |
| max_upload_size | |
| id | 1889442 |
| size | 54,024 |
::droppable-pinThe eponoymous droppable_pin! macro around a given let var = pin!() declaration allows
invoking pin_drop! and pin_set! on the given var, which have in turn been designed to
avoid silly borrow-checking errors.

# async {
#
use ::core::pin::pin;
use ::droppable_pin::{droppable_pin, pin_drop, pin_set}; // 👈
use ::futures_util::future::{Fuse, FusedFuture, FutureExt};
async fn foo() {}
async fn bar(_borrowed: &mut i32) {}
let mut borrowed = 42;
droppable_pin! { // 👈
let mut a = pin!(Fuse::terminated()); // Reminder: `Fuse::terminated()` is akin to `None`,
let mut b = pin!(Fuse::terminated()); // and `future().fuse()`, to `Some(future())`.
}
loop {
if a.is_terminated() {
// 👇
pin_set!(a, foo().fuse());
// same as:
a.set(foo().fuse());
}
if b.is_terminated() {
// 1. Needed because of the `&mut borrowed` capture (see # Motivation).
// 👇
pin_drop!(b);
pin_set!(b, bar(&mut borrowed).fuse());
// 👆
// 2. Cannot use `Pin::set()` here because of `pin_drop!()`.
}
::futures_util::select! {
() = a.as_mut() => {
/* handle this case... */
# if true { break; }
},
() = b.as_mut() => {
/* handle this case... */
},
}
}
#
# };
See the docs of droppable_pin! for more information and the motivation behind this.