October 2019
Intermediate to advanced
444 pages
10h 37m
English
Automated testing with macros is only a few steps away:
use std::ops::{Add, Mul, Sub};macro_rules! assert_equal_len { // The `tt` (token tree) designator is used for // operators and tokens. ($a:ident, $b: ident, $func:ident) => ( assert_eq!($a.len(), $b.len(), "{:?}: dimension mismatch: {:?} {:?}", stringify!($func), ($a.len(),), ($b.len(),)); )}
macro_rules! op { ($func:ident, $bound:ident, $method:ident) => ( pub fn ...Read now
Unlock full access