wopt 0.4.3

A procedural macro that automatically generates an Option-wrapped version of a struct, reducing boilerplate for optional updates.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::fs;
use std::path::Path;

fn main() {
    println!("cargo:rerun-if-changed=build.rs"); // rerun if build.rs itself changes
    println!("cargo:rerun-if-changed="); // empty means always rerun

    let path = Path::new("target/wopt/counter");

    // Ensure directory exists
    if let Some(parent) = path.parent() {
        fs::create_dir_all(parent).unwrap();
    }
    // Reset counter to "0" every rebuild
    fs::write(path, b"0").unwrap();
}