2个版本
0.1.1 | 2021年9月19日 |
---|---|
0.1.0 | 2021年9月19日 |
#9 in #source-string
每月42次下载
7KB
85 代码行
include_path
此crate提供了一组宏的实现,用于补充Rust中现有的include_*
宏,接受可变数量的参数,在编译时将它们组合成特定平台的路径字符串,并返回相应的底层宏
您可以在crate文档中查看使用示例。
lib.rs
:
一种跨平台的include!源、字符串和字节的实现方法
此crate提供了一组宏的实现,用于补充Rust中现有的include_*
宏,接受可变数量的参数,在编译时将它们组合成特定平台的路径字符串,并返回相应的底层宏
示例
// This code assumes the file "../res-tests/include.txt" exists and contains the following:
// ```
// include = "Test String"
// ```
// This code will compile in both Windows systems and Unix-based systems
use include_path::include_path;
let include;
include_path!("..","res-tests","include.txt");
assert_eq!("Test String",include);
// This code assumes the file "../res-tests/include_bytes.txt" exists and contains the following UTF-8 encoded text:
// ```
// Test Bytes
// ```
// This code will compile in both Windows systems and Unix-based systems
use include_path::include_path_bytes;
let include_bytes = include_path_bytes!("..","res-tests","include_bytes.txt");
assert_eq!("Test Bytes".as_bytes(),include_bytes);
// This code assumes the file "../res-tests/include_str.txt" exists and contains the following:
// ```
// Test String
// ```
// This code will compile in both Windows systems and Unix-based systems
use include_path::include_path_str;
let include_str = include_path_str!("..","res-tests","include_str.txt");
assert_eq!("Test String",include_str);
依赖关系
~235KB