1 unstable release

0.1.0 Jul 1, 2023

#1618 in Procedural macros

MIT license

3KB

Get the source code of a code block as a static string.

Example

fn main() {
    let (k, src) = shower::source!(|| {
        for i in 0..5 {
            println!("{}", i);
        }
        "{abc}"
    });

    // print the source code of the program
    println!("{}", src);

    println!("running program:");
    let k = k();

    println!("program returned={}", k);

}

Output

shower::source!(|| {
    for i in 0..5 {
        println!("{}", i);
    }
    "{abc}"
})
running program:
0
1
2
3
4
program returned={abc}

Dependencies

~250–700KB
~17K SLoC