diff --git a/dotenvy-macros/src/lib.rs b/dotenvy-macros/src/lib.rs index f508a53..12c1db9 100644 --- a/dotenvy-macros/src/lib.rs +++ b/dotenvy-macros/src/lib.rs @@ -71,9 +71,9 @@ pub fn load(attr: TokenStream, item: TokenStream) -> TokenStream { // this works with `tokio::main`` but not `async_std::main`` quote! { // non-async wrapper function - #vis fn #fn_name() #output { + #vis async fn #fn_name() #output { #load_env - #new_fn_name() + #new_fn_name().await } // orig async function, but renamed diff --git a/examples/async-std-dotenvy/.env b/examples/async-std-dotenvy/.env new file mode 100644 index 0000000..e69de29 diff --git a/examples/async-std-dotenvy/Cargo.toml b/examples/async-std-dotenvy/Cargo.toml new file mode 100644 index 0000000..7d87ffb --- /dev/null +++ b/examples/async-std-dotenvy/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "async-std-dotenvy" +version = "0.1.0" +edition = "2021" + +[dependencies] +async-std = { version = "1.12.0", features = ["attributes"] } +dotenvy = { path = "../../dotenvy" } \ No newline at end of file diff --git a/examples/async-std-dotenvy/src/main.rs b/examples/async-std-dotenvy/src/main.rs new file mode 100644 index 0000000..92ca5c2 --- /dev/null +++ b/examples/async-std-dotenvy/src/main.rs @@ -0,0 +1,5 @@ +#[async_std::main] +#[dotenvy::load] +async fn main() { + println!("Hello, world!"); +} diff --git a/examples/tokio-dotenvy/.env b/examples/tokio-dotenvy/.env new file mode 100644 index 0000000..e69de29 diff --git a/examples/tokio-dotenvy/Cargo.toml b/examples/tokio-dotenvy/Cargo.toml new file mode 100644 index 0000000..eefc1ea --- /dev/null +++ b/examples/tokio-dotenvy/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "tokio-dotenvy" +version = "0.1.0" +edition = "2021" + +[dependencies] +dotenvy = { path = "../../dotenvy" } +tokio = { version = "1", features = ["macros", "rt", "rt-multi-thread"]} \ No newline at end of file diff --git a/examples/tokio-dotenvy/src/main.rs b/examples/tokio-dotenvy/src/main.rs new file mode 100644 index 0000000..1e23d2e --- /dev/null +++ b/examples/tokio-dotenvy/src/main.rs @@ -0,0 +1,5 @@ +#[tokio::main] +#[dotenvy::load] +async fn main() { + println!("hello world") +} \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..7302755 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1 @@ +toolchain.channel = "nightly" \ No newline at end of file