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/ty.rs b/src/ty.rs
index 4fb3328..7345da7 100644
--- a/src/ty.rs
+++ b/src/ty.rs
@@ -69,7 +69,7 @@
}
ast_enum! {
- #[derive(Copy)]
+ #[cfg_attr(feature = "clone-impls", derive(Copy))]
pub enum Mutability {
Mutable,
Immutable,
@@ -234,7 +234,7 @@
}
ast_enum! {
- #[derive(Copy)]
+ #[cfg_attr(feature = "clone-impls", derive(Copy))]
pub enum Unsafety {
Unsafe,
Normal,
@@ -422,7 +422,7 @@
named!(ty_path -> Ty, do_parse!(
qpath: qpath >>
parenthesized: cond!(
- qpath.1.segments.last().unwrap().parameters == PathParameters::none(),
+ qpath.1.segments.last().unwrap().parameters.is_empty(),
option!(parenthesized_parameter_data)
) >>
bounds: many0!(preceded!(punct!("+"), ty_param_bound)) >>
@@ -605,7 +605,7 @@
bound_lifetimes: bound_lifetimes >>
trait_ref: path >>
parenthesized: option!(cond_reduce!(
- trait_ref.segments.last().unwrap().parameters == PathParameters::none(),
+ trait_ref.segments.last().unwrap().parameters.is_empty(),
parenthesized_parameter_data
)) >>
({