mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #14296 - Wafflespeanut:either, r=emilio
Some generic impls for Either<Length, T> <!-- Please describe your changes on the following line: --> We seem to be using `parse_non_negative` a lot for `LengthOrFoo` types, so it's better to have generic impls (now, and in the future) for such things (assuming that `Length` will always be in the first variant of `Either`). --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] These changes do not require tests because it's a refactor <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14296) <!-- Reviewable:end -->
This commit is contained in:
commit
bcf4184483
1 changed files with 7 additions and 7 deletions
|
@ -343,6 +343,13 @@ impl Parse for Length {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Either<Length, T> {
|
||||
#[inline]
|
||||
pub fn parse_non_negative_length(input: &mut Parser) -> Result<Either<Length, T>, ()> {
|
||||
Length::parse_internal(input, AllowedNumericType::NonNegative).map(Either::First)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CalcSumNode {
|
||||
pub products: Vec<CalcProductNode>,
|
||||
|
@ -946,13 +953,6 @@ impl Parse for LengthOrPercentageOrNone {
|
|||
|
||||
pub type LengthOrNone = Either<Length, None_>;
|
||||
|
||||
impl LengthOrNone {
|
||||
#[inline]
|
||||
pub fn parse_non_negative(input: &mut Parser) -> Result<LengthOrNone, ()> {
|
||||
Length::parse_internal(input, AllowedNumericType::NonNegative).map(Either::First)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Copy, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum LengthOrPercentageOrAutoOrContent {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue