#windows

nightly macro include_path

A cross-platform way to include! source, strings and bytes

2 releases

0.1.1 Sep 19, 2021
0.1.0 Sep 19, 2021

#592 in #windows

Download history 51/week @ 2024-07-27 1/week @ 2024-08-03 2/week @ 2024-08-31 3/week @ 2024-09-07 1/week @ 2024-09-14 34/week @ 2024-09-21 11/week @ 2024-09-28 2/week @ 2024-10-05 22/week @ 2024-10-12 4/week @ 2024-10-19 3/week @ 2024-10-26 25/week @ 2024-11-02

54 downloads per month

Unlicense

7KB
85 lines

include_path

This crate provides an implementation of a proposed set of macros to complement the existing include_*macros in Rust, taking a variadic set of arguments, combining them into a platform-specific path string at compilation time, and returning the corresponding underlying macros

You can view examples of usage in the crate documentation.


lib.rs:

A cross-platform way to include! source, strings and bytes

This crate provides an implementation of a proposed set of macros to complement the existing include_*macros in Rust, taking a variadic set of arguments, combining them into a platform-specific path string at compilation time, and returning the corresponding underlying macros

Examples

// 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);

Dependencies

~230KB