Flatten some pattern matching

This commit is contained in:
Brendan Zabarauskas 2014-05-21 09:10:28 -07:00
parent 3d757cd9ce
commit fe28e20bca

View file

@ -492,32 +492,35 @@ impl LineboxScanner {
} }
let available_width = green_zone.width - self.pending_line.bounds.size.width; let available_width = green_zone.width - self.pending_line.bounds.size.width;
let split = in_box.split_to_width(available_width, line_is_empty); match in_box.split_to_width(available_width, line_is_empty) {
let (left, right) = match split {
None => { None => {
debug!("LineboxScanner: Tried to split unsplittable render box! {}", debug!("LineboxScanner: Tried to split unsplittable render box! Deferring to next \
in_box); line. {}", in_box);
self.work_list.push_front(in_box); self.work_list.push_front(in_box);
return false false
} },
Some((left, right)) => { Some((Some(left_box), Some(right_box))) => {
debug!("LineboxScanner: case=split box did fit; deferring remainder box."); debug!("LineboxScanner: Line break found! Pushing left box to line and deferring \
(left, right) right box to next line.");
// Fall though to push boxes to the line.
}
};
match (left, right) {
(Some(left_box), Some(right_box)) => {
self.push_box_to_line(left_box); self.push_box_to_line(left_box);
self.work_list.push_front(right_box); self.work_list.push_front(right_box);
} true
(Some(left_box), None) => self.push_box_to_line(left_box), },
(None, Some(right_box)) => self.push_box_to_line(right_box), Some((Some(left_box), None)) => {
(None, None) => error!("LineboxScanner: This split case makes no sense!"), debug!("LineboxScanner: Pushing left box to line.");
self.push_box_to_line(left_box);
true
},
Some((None, Some(right_box))) => {
debug!("LineboxScanner: Pushing right box to line.");
self.push_box_to_line(right_box);
true
},
Some((None, None)) => {
error!("LineboxScanner: This split case makes no sense!");
true
},
} }
true
} }
// An unconditional push // An unconditional push