Move all #[derive] impls behind Cargo feature gates
This commit moves all #[derive] annotations behind Cargo feature gates to add
the ability to strip them all out entirely. The `Clone` and `Copy` impls
continue to be enabled by default as they tend to be mega useful but other
equality/hash/debug impls are all default behind the `extra-impls` gate.
This commit, on my computer, has the following timings:
| features | before | after
|-------------------------------|---------|------
| default | 3.67 | 2.96
| *none* | 1.78 | 0.49
| {printing, parsing} | 3.71 | 2.57
| default + {full} | 8.50 | 6.31
| {full} | 3.53 | 0.70
| {full, printing, parsing} | 8.10 | 5.29
Closes #143
diff --git a/src/mac.rs b/src/mac.rs
index e6132e4..dbed4eb 100644
--- a/src/mac.rs
+++ b/src/mac.rs
@@ -89,7 +89,7 @@
}
ast_enum! {
- #[derive(Copy)]
+ #[cfg_attr(feature = "clone-impls", derive(Copy))]
pub enum BinOpToken {
Plus,
Minus,
@@ -106,7 +106,7 @@
ast_enum! {
/// A delimiter token
- #[derive(Copy)]
+ #[cfg_attr(feature = "clone-impls", derive(Copy))]
pub enum DelimToken {
/// A round parenthesis: `(` or `)`
Paren,
@@ -371,8 +371,8 @@
Token::OrOr => tokens.append("||"),
Token::Not => tokens.append("!"),
Token::Tilde => tokens.append("~"),
- Token::BinOp(binop) => tokens.append(binop.op()),
- Token::BinOpEq(binop) => tokens.append(binop.assign_op()),
+ Token::BinOp(ref binop) => tokens.append(binop.op()),
+ Token::BinOpEq(ref binop) => tokens.append(binop.assign_op()),
Token::At => tokens.append("@"),
Token::Dot => tokens.append("."),
Token::DotDot => tokens.append(".."),