| Crates.io | multiple_choice |
| lib.rs | multiple_choice |
| version | 0.1.0 |
| created_at | 2026-01-18 01:23:47.626991+00 |
| updated_at | 2026-01-18 01:23:47.626991+00 |
| description | A Rust proc-macro library that verifies function results through multiple executions |
| homepage | |
| repository | https://github.com/Treagzhao/multiple_choice |
| max_upload_size | |
| id | 2051550 |
| size | 7,203 |
A Rust proc-macro library that provides an attribute macro #[triple_verify] for verifying function results through multiple executions.
The #[triple_verify] attribute macro automatically executes a function three times and compares the results:
#[triple_verify] to any functionPartialEqPartialEq (or tuples/arrays of such types)Add this library as a dependency to your Cargo.toml:
[dependencies]
multiple_choice = { path = "../path/to/multiple_choice" }
extern crate multiple_choice;
use multiple_choice::triple_verify;
#[triple_verify]
fn add(a: i32, b: i32) -> i32 {
a + b
}
#[triple_verify]
fn create_struct(id: i32, name: &str, value: f64) -> MyStruct {
MyStruct {
id,
name: name.to_string(),
value,
}
}
fn main() {
println!("Result: {}", add(2, 3));
}
Result: 5
WARNING: Function add: Two results match, one differs
Result: 5
thread 'main' panicked at src/main.rs:10:1:
Function different_value: All three results differ: 1, 2, 3
The library includes a comprehensive test project that verifies:
To run the tests:
cd test_project
cargo test
MIT