Dup Goto 📝

Rust Compile Time Macros 001

PT2/lang/rust/examples rust 01-19 19:44:01
To Pop
15 lines, 55 words, 318 chars Friday 2024-01-19 19:44:01

This takes the PATH variable, as it was when the binary was compiled. This does not fetch the PATH variable at runtime. This is why it can be a const fn.

use std;

const fn mac() -> &'static str {
    let path: &'static str = std::env!("PATH");
    path
}

fn main() {
    println!("{}",mac());
}