Function build_script_file_gen::gen_file_str [] [src]

pub fn gen_file_str(file_name: &str, content: &str)

When used inside a build script (build.rs), generates a file under the specified file name and includes the specified utf8-encoded string as its content.

The file is created relative to the path denoted by the OUT_DIR environment variable at build time.

Examples

extern crate build_script_file_gen;
use build_script_file_gen::gen_file_str;

fn main() {
    let string_content = "Hello World!";
    gen_file_str("hello.txt", &string_content);
}
extern crate build_script_file_gen;
use build_script_file_gen::gen_file_str;

fn main() {
    let rust_code = r#"println!("Hello World!");"#;
    gen_file_str("hello.rs", &rust_code);
}