diff --git a/adb_cli/src/main.rs b/adb_cli/src/main.rs index b7e0f2f..14605b2 100644 --- a/adb_cli/src/main.rs +++ b/adb_cli/src/main.rs @@ -25,9 +25,15 @@ use std::path::Path; use utils::setup_logger; fn main() -> Result<()> { + // This depends on `clap` let opts = Opts::parse(); - setup_logger(opts.debug); + // SAFETY: + // We are assuming the entire process is single-threaded + // at this point. + // This seems true for the current version of `clap`, + // but there's no guarantee for future updates + unsafe { setup_logger(opts.debug) }; // Directly handling methods / commands that aren't linked to [`ADBDeviceExt`] trait. // Other methods just have to create a concrete [`ADBDeviceExt`] instance, and return it. diff --git a/adb_cli/src/utils.rs b/adb_cli/src/utils.rs index 57e49f5..b5b01db 100644 --- a/adb_cli/src/utils.rs +++ b/adb_cli/src/utils.rs @@ -1,4 +1,8 @@ -pub fn setup_logger(debug: bool) { +/// # Safety +/// +/// This conditionally mutates the process' environment. +/// See [`std::env::set_var`] for more info. +pub unsafe fn setup_logger(debug: bool) { // RUST_LOG variable has more priority then "--debug" flag if std::env::var("RUST_LOG").is_err() { let level = match debug {