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

macro build include_tt

Macro for embedding (trees, strings, arrays) into macro trees directly from files

4 stable releases

1.0.3 Apr 3, 2024
1.0.2 Aug 4, 2023
1.0.1 Jul 27, 2023
1.0.0 Jul 23, 2023

#176 in Build Utils

Download history 2/week @ 2024-02-14 20/week @ 2024-02-21 18/week @ 2024-02-28 2/week @ 2024-03-06 5/week @ 2024-03-13 2/week @ 2024-03-27 185/week @ 2024-04-03 2/week @ 2024-04-10

189 downloads per month

MIT/Apache

39KB
881 lines

[include_tt]

(Macro for embedding (trees, strings, arrays) into macro trees directly from files.)

Usage:

Add this to your Cargo.toml:

[dependencies]
include_tt = "1.0.3"

and this to your source code:

use include_tt::include_tt;

Example:

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: {}",
			
			// This file contains `a, b`.
			#include!("./for_examples/full.tt")
		);
	}
	
	// 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")
	);
	
	// 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")
	);
	
	// Asserting the result matches the expected output.
	assert_eq!(array, b"a, b");
}
See all

License:

This project has a dual license according to (LICENSE-MIT) and (LICENSE-APACHE-2-0).

uproject  Copyright (c) 2023-2024 #UlinProject

 (Denis Kotlyarov).


Apache License:

apache2  Licensed under the Apache License, Version 2.0.



MIT License:

mit  Licensed under the MIT License.



Dependencies

~340–800KB
~19K SLoC