-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preliminary fix of dotenvy attribute to work with async_std
- Loading branch information
1 parent
fa19b77
commit 2396aa9
Showing
10 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#![feature(prelude_import)] | ||
#[prelude_import] | ||
use std::prelude::rust_2021::*; | ||
#[macro_use] | ||
extern crate std; | ||
fn main() { | ||
async fn main() { | ||
use dotenvy::{EnvLoader, EnvSequence}; | ||
use std::{ | ||
error::Error, io::{self, ErrorKind}, | ||
process, | ||
}; | ||
let seq = if false { EnvSequence::InputOnly } else { EnvSequence::InputThenEnv }; | ||
let mut loader = EnvLoader::from_path(".env").sequence(seq); | ||
if let Err(e) = unsafe { loader.load_and_modify() } { | ||
if let Some(io_err) = e | ||
.source() | ||
.and_then(|src| src.downcast_ref::<io::Error>()) | ||
{ | ||
if io_err.kind() == io::ErrorKind::NotFound && !true {} | ||
} | ||
{ | ||
::std::io::_eprint( | ||
format_args!( | ||
"Failed to load env file from path \'{0}\': {1}\n", | ||
".env", | ||
e, | ||
), | ||
); | ||
}; | ||
process::exit(1); | ||
} | ||
main_inner() | ||
} | ||
async fn main_inner() { | ||
{ | ||
{ | ||
{ | ||
::std::io::_print(format_args!("Hello, world!\n")); | ||
}; | ||
} | ||
} | ||
} | ||
async_std::task::block_on(async { main().await }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[async_std::main] | ||
#[dotenvy::load] | ||
async fn main() { | ||
println!("Hello, world!"); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![feature(prelude_import)] | ||
#[prelude_import] | ||
use std::prelude::rust_2021::*; | ||
#[macro_use] | ||
extern crate std; | ||
fn main() { | ||
let body = async { | ||
{ | ||
::std::io::_print(format_args!("hello world\n")); | ||
} | ||
}; | ||
#[allow(clippy::expect_used, clippy::diverging_sub_expression)] | ||
{ | ||
return tokio::runtime::Builder::new_multi_thread() | ||
.enable_all() | ||
.build() | ||
.expect("Failed building the Runtime") | ||
.block_on(body); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[tokio::main] | ||
#[dotenvy::load] | ||
async fn main() { | ||
println!("hello world") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
toolchain.channel = "nightly" |