some_executor 0.7.2

A trait for libraries that abstract over any executor
Documentation
// SPDX-License-Identifier: MIT OR Apache-2.0
//! The shortest thing `#[some_executor::main]` can be written as, and the
//! fallible form.
//!
//! No backend argument, so this runs on the built-in fallback executor. That is
//! what makes an example like this a single file with no dependency on a
//! particular runtime -- and also why the fallback prints a warning when it
//! starts. A real program names its backend.
//!
//! The `-> Result` is the other half: the macro never looks at the declared
//! return type, so this compiles for the same reason a `-> ()` one does. An
//! `Err` here would be logged and would panic; see
//! `some_executor::entry_point::MainResult`.
//!
//! Run with: `cargo run --example main_macro_default`

#[some_executor::main]
async fn main() -> Result<(), String> {
    let installed = some_executor::global_executor::global_executor(|e| e.is_some());
    println!("running on the default backend; a global executor is installed: {installed}");
    if !installed {
        return Err("the backend did not install itself".to_string());
    }
    Ok(())
}