#byte #hash-map #import

include-files

将文件字节导入HashMap

0.1.2 2022年4月12日
0.1.1 2022年4月12日
0.1.0 2022年4月12日

#123 in #import

MIT许可证

5KB
56

include-files

将文件字节导入HashMap

用法

Cargo.toml

[dependencies]
once_cell = "1.10.0"

[build-dependencies]
include-files = "*"

build.rs

fn main() {
    let target = std::env::var("OUT_DIR").unwrap();
    include_files::IncludeFiles::new("./assets", "png", target).build().unwrap();
}

src/example.rs

// Import build.rs output file
include!(env!("INCLUDE_FILES_PATH"));

for item in INCLUDE_FILES {
    println!("{:?}", item);
}

lib.rs:

用法

Cargo.toml

[dependencies]
once_cell = "1.10.0"

[build-dependencies]
include-files = "*"

build.rs

fn main() {
    let target = std::env::var("OUT_DIR").unwrap();
    include_files::IncludeFiles::new("./assets", "png", target).build().unwrap();
}

src/example.rs

// Import build.rs output file
include!(env!("INCLUDE_FILES_PATH"));

for item in INCLUDE_FILES {
    println!("{:?}", item);
}

无运行时依赖