INNER CODE UNIT · Rust

get_int_from_env

ngless-toolkit/ngless · src/batch.rs:41

fn get_int_from_env<T: std::str::FromStr>(var: &str) -> Option<T> {
    env::var(var).ok().and_then(|v| v.parse().ok())
}

#[cfg(test)]
mod tests {
    use super::*;

    // All `batch` environment variables, cleared around each assertion. These variables are not
    // touched by any other test, but env mutation is process-global, so everything runs inside one
    // test function to keep it deterministic regardless of test-thread scheduling.
    const VARS: &[&str] = &[
        "LSB_JOBINDEX",
        "SGE_TASK_ID",
        "OMP_NUM_THREADS",
        "NSLOTS",
        "LSB_DJOB_NUMPROC",
        "SLURM_CPUS_PER_TASK",

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…