Use Option::expect instead of pattern matching in try_append_to_line_by_new_line

This commit is contained in:
Brendan Zabarauskas 2014-06-20 10:50:40 -07:00
parent 344af248e7
commit 762669b5c6

View file

@ -477,8 +477,10 @@ impl LineBreaker {
true true
} else { } else {
debug!("LineBreaker: Found a new-line character, so splitting theline."); debug!("LineBreaker: Found a new-line character, so splitting theline.");
match in_fragment.find_split_info_by_new_line() {
Some((left, right, run)) => { let (left, right, run) = in_fragment.find_split_info_by_new_line()
.expect("LineBreaker: This split case makes no sense!");
// TODO(bjz): Remove fragment splitting // TODO(bjz): Remove fragment splitting
let split_fragment = |split: SplitInfo| { let split_fragment = |split: SplitInfo| {
let info = ScannedTextFragmentInfo::new(run.clone(), split.range); let info = ScannedTextFragmentInfo::new(run.clone(), split.range);
@ -490,7 +492,7 @@ impl LineBreaker {
debug!("LineBreaker: Pushing the fragment to the left of the new-line character \ debug!("LineBreaker: Pushing the fragment to the left of the new-line character \
to the line."); to the line.");
let mut left = split_fragment(left); let mut left = split_fragment(left);
left.new_line_pos = vec!(); left.new_line_pos = vec![];
self.push_fragment_to_line(left); self.push_fragment_to_line(left);
for right in right.move_iter() { for right in right.move_iter() {
@ -500,11 +502,6 @@ impl LineBreaker {
right.new_line_pos = in_fragment.new_line_pos.clone(); right.new_line_pos = in_fragment.new_line_pos.clone();
self.work_list.push_front(right); self.work_list.push_front(right);
} }
},
None => {
error!("LineBreaker: This split case makes no sense!")
},
}
false false
} }
} }