style: Remove the paper size variant of GenericPageSize and add an implied default to the paper size and orientation variant

Differential Revision: https://phabricator.services.mozilla.com/D119915
This commit is contained in:
Emily McDonough 2023-05-22 10:09:22 +02:00 committed by Oriol Brufau
parent 45d6e64d51
commit c2a50c92fa
3 changed files with 21 additions and 20 deletions

View file

@ -23,15 +23,15 @@ impl Parse for PageSize {
) -> Result<Self, ParseError<'i>> {
// Try to parse as <page-size> [ <orientation> ]
if let Ok(paper_size) = input.try_parse(PaperSize::parse) {
if let Ok(orientation) = input.try_parse(Orientation::parse) {
return Ok(PageSize::PaperSizeAndOrientation(paper_size, orientation));
}
return Ok(PageSize::PaperSize(paper_size));
let orientation = input
.try_parse(Orientation::parse)
.unwrap_or(Orientation::Portrait);
return Ok(PageSize::PaperSize(paper_size, orientation));
}
// Try to parse as <orientation> [ <page-size> ]
if let Ok(orientation) = input.try_parse(Orientation::parse) {
if let Ok(paper_size) = input.try_parse(PaperSize::parse) {
return Ok(PageSize::PaperSizeAndOrientation(paper_size, orientation));
return Ok(PageSize::PaperSize(paper_size, orientation));
}
return Ok(PageSize::Orientation(orientation));
}