pinky-swear

Crates.iopinky-swear
lib.rspinky-swear
version6.2.1
created_at2019-10-28 14:46:43.161142+00
updated_at2025-08-15 15:47:55.129183+00
descriptionFutures and async/await-ready Promises
homepage
repositoryhttps://github.com/amqp-rs/pinky-swear
max_upload_size
id176384
size19,148
Marc-Antoine Perennou (Keruspe)

documentation

https://docs.rs/pinky-swear

README

Simple promise library compatible with std::future and async/await

API Docs Build status Downloads

Example

Create a promise and wait for the result while computing the result in another thread

use pinky_swear::{Pinky, PinkySwear};
use std::{thread, time::Duration};

fn compute(pinky: Pinky<Result<u32, ()>>) {
    thread::sleep(Duration::from_millis(1000));
    pinky.swear(Ok(42));
}

fn main() {
    let (promise, pinky) = PinkySwear::new();
    thread::spawn(move || {
        compute(pinky);
    });
    assert_eq!(promise.wait(), Ok(42));
}
Commit count: 123

cargo fmt