mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
style: Add a Zero trait that doesn't require Add, and use it in place of num_traits and IsZeroLength.
Use it to be consistent in InsetRect serialization and storage between Servo and Gecko. Differential Revision: https://phabricator.services.mozilla.com/D21493
This commit is contained in:
parent
4496411edc
commit
7d01114cbf
29 changed files with 179 additions and 186 deletions
|
@ -244,3 +244,26 @@ impl CaseSensitivityExt for selectors::attr::CaseSensitivity {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait pretty much similar to num_traits::Zero, but without the need of
|
||||
/// implementing `Add`.
|
||||
pub trait Zero {
|
||||
/// Returns the zero value.
|
||||
fn zero() -> Self;
|
||||
|
||||
/// Returns whether this value is zero.
|
||||
fn is_zero(&self) -> bool;
|
||||
}
|
||||
|
||||
impl<T> Zero for T
|
||||
where
|
||||
T: num_traits::Zero,
|
||||
{
|
||||
fn zero() -> Self {
|
||||
<Self as num_traits::Zero>::zero()
|
||||
}
|
||||
|
||||
fn is_zero(&self) -> bool {
|
||||
<Self as num_traits::Zero>::is_zero(self)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue