1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
use dotenv::dotenv; use std::env; pub struct Config { pub api_key: String, } impl Config { pub fn from_env() -> Result<Self, env::VarError> { dotenv().ok(); Ok(Self { api_key: env::var("API_KEY")?, }) } }