#macro #proc-macro #clucompany #code-generation #code-transformation #file-content

macro build include_tt

宏用于将(树、字符串、数组)直接从文件嵌入到宏树中

5 个稳定版本

1.0.4 2024 年 5 月 14 日
1.0.3 2024 年 4 月 3 日
1.0.2 2023 年 8 月 4 日
1.0.1 2023 年 7 月 27 日
1.0.0 2023 年 7 月 23 日

#151 in 构建工具

Download history 8/week @ 2024-04-07 112/week @ 2024-05-12 16/week @ 2024-05-19 13/week @ 2024-06-02 26/week @ 2024-06-09 37/week @ 2024-06-16 2/week @ 2024-06-23

每月下载量 335

MIT/Apache

39KB
854

[include_tt]

(宏用于将(树、字符串、数组)直接从文件嵌入到宏树中。)

使用方法

将此内容添加到您的 Cargo.toml 文件中

[dependencies]
include_tt = "1.0.4"

并将此内容添加到您的源代码中

use include_tt::include_tt;

示例

use include_tt::include_tt;
use std::fmt::Write;

// Example demonstrating the usage of include_tt! macro for embedding content from files.
{ 
	// Embedding trees from a file in an arbitrary place of other macros.
	let a = 10;
	let b = 20;
	let mut end_str = String::new();
	
	// Using include_tt! to embed content into a macro.
	include_tt! {
		let _e = write!(
			&mut end_str,
			
			"arg1: {}, arg2: {}",
			#include!("./for_examples/full.tt") // this file contains `a, b`.
		);
	}
	
	// Asserting the result matches the expected output.
	assert_eq!(end_str, "arg1: 10, arg2: 20");
}

{ 
	// Loading a string from "full.tt" using include_tt! macro.
	let str = include_tt!(
		#include_str!("./for_examples/full.tt") // this file contains `a, b`.
	);
	
	// Asserting the result matches the expected output.
	assert_eq!(str, "a, b");
}

{
	// Loading a array from "full.tt" using include_tt! macro.
	let array: &'static [u8; 4] = include_tt!(
		#include_arr!("./for_examples/full.tt") // this file contains `a, b`.
	);
	
	// Asserting the result matches the expected output.
	assert_eq!(array, b"a, b");
}
查看全部

许可证

本项目根据 (LICENSE-MIT) 和 (LICENSE-APACHE-2-0) 具有双重许可证。

uproject  版权 (c) 2023-2024 #UlinProject

 (Denis Kotlyarov).


Apache 许可证

apache2  根据 Apache 许可证版本 2.0 许可。



MIT 许可证

mit  根据 MIT 许可证许可。



依赖关系

~275–720KB
~17K SLoC