Skip to content

Doc request: full minimal working example, including main #32

Description

@sullyj3

Hi! I'm interested in using this library. However, as someone who hasn't done concurrency in rust before, I'm not quite sure how to get started.

The main docs page has this example:

async fn scoped_futures() {
    let not_copy = String::from("hello world!");
    let not_copy_ref = &not_copy;
    let (foo, outputs) = async_scoped::AsyncStdScope::scope_and_block(|s| {
        for _ in 0..10 {
            let proc = || async {
                assert_eq!(not_copy_ref, "hello world!");
                eprintln!("Hello world!")
            };
            s.spawn(proc());
        }
        42
    });
    assert_eq!(foo, 42);
    assert_eq!(outputs.len(), 10);
}

But I'm not sure how to execute an async fn. This means as a beginner, I have to go and look at the async-std or tokio docs to understand how to use this library, which is perhaps intended to be an abstraction layer over the top of them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions