style: Derive more.

Differential Revision: https://phabricator.services.mozilla.com/D17029
This commit is contained in:
Bobby Holley 2019-01-18 12:39:29 -08:00 committed by Emilio Cobos Álvarez
parent 137e735d9d
commit af1bbd7b06
8 changed files with 14 additions and 91 deletions

View file

@ -304,7 +304,7 @@ impl ElementCascadeInputs {
/// Statistics gathered during the traversal. We gather statistics on each
/// thread and then combine them after the threads join via the Add
/// implementation below.
#[derive(Default)]
#[derive(AddAssign, Clone, Default)]
pub struct PerThreadTraversalStatistics {
/// The total number of elements traversed.
pub elements_traversed: u32,
@ -319,20 +319,6 @@ pub struct PerThreadTraversalStatistics {
pub styles_reused: u32,
}
/// Implementation of Add to aggregate statistics across different threads.
impl<'a> ops::Add for &'a PerThreadTraversalStatistics {
type Output = PerThreadTraversalStatistics;
fn add(self, other: Self) -> PerThreadTraversalStatistics {
PerThreadTraversalStatistics {
elements_traversed: self.elements_traversed + other.elements_traversed,
elements_styled: self.elements_styled + other.elements_styled,
elements_matched: self.elements_matched + other.elements_matched,
styles_shared: self.styles_shared + other.styles_shared,
styles_reused: self.styles_reused + other.styles_reused,
}
}
}
/// Statistics gathered during the traversal plus some information from
/// other sources including stylist.
#[derive(Default)]