interpolate_idents | Useable macro identifier concatenation plugin for Rust | Reflection library
kandi X-RAY | interpolate_idents Summary
kandi X-RAY | interpolate_idents Summary
Warning! This crate uses a procedural macro (known today as a compiler plugin) and can only be used with Rust's nightly distribution. You cannot currently define a struct, enum, function, or field using concat_idents! due to the way macros are parsed by the Rust compiler. This will hopefully change in the future, but interpolate_idents! sloppily solves a side effect of the currently lacking macro system today. Now make_fn!(favorite); is equivalent to fn my_favorite_fn() -> u32 { 1000 }. In short, surround multiple space-separated identifiers (or macro identifer variables) with square brackets to concatenate the identifiers. Check tests/tests.rs for another example. This plugin was quickly hacked together. It is likely not performant and most certainly not readable.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of interpolate_idents
interpolate_idents Key Features
interpolate_idents Examples and Code Snippets
Community Discussions
Trending Discussions on interpolate_idents
QUESTION
A few questions (such as How can I create parameterized tests in Rust?) deal with using macros to create parameterised unit tests in Rust. I need to use this technique to generate a pair of unit tests for every pair of input files in a directory. The unit tests themselves just call a simple function:
...ANSWER
Answered 2018-Mar-01 at 19:07The trouble with your attempted approach at parameterized tests is that TEST_FILES
is computed only at runtime, while you are expecting to be able to use it at compile time to stamp out the several #[test]
functions.
In order to make this work, you will need some way to compute TEST_FILES
at compile time. One possibility would be through a build script that iterates the glob at build time and writes out #[test]
functions to a file that can be included from your test directory.
Cargo.toml
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install interpolate_idents
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page