mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 23:32:39 +00:00
fmt: remove crash! macro (#5589)
* fmt: remove crash! macro * Fix styling in fmt * Revert "Fix styling in fmt" This reverts commit002e02f50c
. * Revert "fmt: remove crash! macro" This reverts commitd65a3f85a1
. * Replace crash! with unreachable! macro * Remove crash! import * Remove unreachable! from fmt * keep the helpful comment * Fix lint and format issues * review fixes
This commit is contained in:
parent
2e6005a902
commit
3a7a3bf639
1 changed files with 18 additions and 22 deletions
|
@ -8,8 +8,6 @@
|
|||
use std::io::{BufWriter, Stdout, Write};
|
||||
use std::{cmp, i64, mem};
|
||||
|
||||
use uucore::crash;
|
||||
|
||||
use crate::parasplit::{ParaWords, Paragraph, WordInfo};
|
||||
use crate::FmtOptions;
|
||||
|
||||
|
@ -363,16 +361,12 @@ fn find_kp_breakpoints<'a, T: Iterator<Item = &'a WordInfo<'a>>>(
|
|||
}
|
||||
|
||||
fn build_best_path<'a>(paths: &[LineBreak<'a>], active: &[usize]) -> Vec<(&'a WordInfo<'a>, bool)> {
|
||||
let mut breakwords = vec![];
|
||||
// of the active paths, we select the one with the fewest demerits
|
||||
let mut best_idx = match active.iter().min_by_key(|&&a| paths[a].demerits) {
|
||||
None => crash!(
|
||||
1,
|
||||
"Failed to find a k-p linebreak solution. This should never happen."
|
||||
),
|
||||
Some(&s) => s,
|
||||
};
|
||||
|
||||
active
|
||||
.iter()
|
||||
.min_by_key(|&&a| paths[a].demerits)
|
||||
.map(|&(mut best_idx)| {
|
||||
let mut breakwords = vec![];
|
||||
// now, chase the pointers back through the break list, recording
|
||||
// the words at which we should break
|
||||
loop {
|
||||
|
@ -385,6 +379,8 @@ fn build_best_path<'a>(paths: &[LineBreak<'a>], active: &[usize]) -> Vec<(&'a Wo
|
|||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
// "infinite" badness is more like (1+BAD_INFTY)^2 because of how demerits are computed
|
||||
|
|
Loading…
Reference in a new issue