Skip to content

Commit

Permalink
Update dry.md (#181)
Browse files Browse the repository at this point in the history
* Update dry.md

* Update dry.md

---------

Co-authored-by: YangQi <2419731931@qq.com>
  • Loading branch information
fake-rick and YangFong authored Jan 13, 2024
1 parent 0c2acb6 commit 977483e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/macros/dry.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ use std::ops::{Add, Mul, Sub};
macro_rules! assert_equal_len {
// `tt`(token tree,标记树)指示符表示运算符和标记。
($a:ident, $b: ident, $func:ident, $op:tt) => (
($a:ident, $b: ident, $func:ident, $op:tt) => {
assert!($a.len() == $b.len(),
"{:?}: dimension mismatch: {:?} {:?} {:?}",
stringify!($func),
($a.len(),),
stringify!($op),
($b.len(),));
)
};
}
macro_rules! op {
($func:ident, $bound:ident, $op:tt, $method:ident) => (
($func:ident, $bound:ident, $op:tt, $method:ident) => {
fn $func<T: $bound<T, Output=T> + Copy>(xs: &mut Vec<T>, ys: &Vec<T>) {
assert_equal_len!(xs, ys, $func, $op);
Expand All @@ -27,7 +27,7 @@ macro_rules! op {
// *x = x.$method(*y);
}
}
)
};
}
// 实现 `add_assign`、`mul_assign` 和 `sub_assign` 等函数。
Expand Down

0 comments on commit 977483e

Please sign in to comment.