1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-02 19:32:25 +01:00

Fix some clippy lints

Some might actually improve perf
This commit is contained in:
Lzu Tao
2020-04-24 13:46:01 +07:00
committed by David Peter
parent a4828387c1
commit e37e9c1214
12 changed files with 30 additions and 33 deletions

View File

@@ -36,15 +36,12 @@ pub fn expand_tabs(line: &str, width: usize, cursor: &mut usize) -> String {
fn try_parse_utf8_char(input: &[u8]) -> Option<(char, usize)> {
let str_from_utf8 = |seq| std::str::from_utf8(seq).ok();
let decoded = None
.or(input.get(0..1).and_then(str_from_utf8).map(|c| (c, 1)))
.or(input.get(0..2).and_then(str_from_utf8).map(|c| (c, 2)))
.or(input.get(0..3).and_then(str_from_utf8).map(|c| (c, 3)))
.or(input.get(0..4).and_then(str_from_utf8).map(|c| (c, 4)));
let decoded = input.get(0..1).and_then(str_from_utf8).map(|c| (c, 1))
.or_else(|| input.get(0..2).and_then(str_from_utf8).map(|c| (c, 2)))
.or_else(|| input.get(0..3).and_then(str_from_utf8).map(|c| (c, 3)))
.or_else(|| input.get(0..4).and_then(str_from_utf8).map(|c| (c, 4)));
let decoded_char = decoded.map(|(seq, n)| (seq.chars().next().unwrap(), n));
decoded_char
decoded.map(|(seq, n)| (seq.chars().next().unwrap(), n))
}
pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String {