Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #[dotenvy::load] and #[async-std::main] used on one function #119

Draft
wants to merge 2 commits into
base: v0.16
Choose a base branch
from

Conversation

aidenfarley
Copy link

Will eventually close #117

Adds support for async-std along with the new load macro for dotenvy. Also includes an example with tokio and the new macro.

(Apologies for creating a second PR. I did not properly name my branch before opening the previous one.)

@aidenfarley
Copy link
Author

@allan2 While the process might be convoluted, is there anything inherently wrong with the changes I made?
If dotenvy is the first thing to be run, and it doesn't use any asynchronous calls, what is the requirement to have it be in a synchronous function?

@allan2
Copy link
Owner

allan2 commented Sep 5, 2024

Please read the std::env::set_var safety notice.

This makes it not practically possible for you to guarantee that no other thread will read the environment, so the only safe option is to not use set_var or remove_var in multi-threaded programs at all.

Two comments:

  • #[load] should be on top of #[async_std::main]
  • no need to have the expansion output in the repo
  • just an example parallel to the tokio example will suffice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants