mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-04 15:07:47 +00:00
refactor/polish ~ fix cargo clippy
complaints (use b'...' notation)
This commit is contained in:
parent
b276f4758f
commit
768ed71725
5 changed files with 12 additions and 12 deletions
|
@ -336,7 +336,7 @@ fn display_dir_entry_size(entry: &PathBuf, options: &getopts::Matches) -> (usize
|
||||||
fn pad_left(string: String, count: usize) -> String {
|
fn pad_left(string: String, count: usize) -> String {
|
||||||
if count > string.len() {
|
if count > string.len() {
|
||||||
let pad = count - string.len();
|
let pad = count - string.len();
|
||||||
let pad = String::from_utf8(vec![' ' as u8; pad]).unwrap();
|
let pad = String::from_utf8(vec![b' ' as u8; pad]).unwrap();
|
||||||
format!("{}{}", pad, string)
|
format!("{}{}", pad, string)
|
||||||
} else {
|
} else {
|
||||||
string
|
string
|
||||||
|
|
|
@ -179,9 +179,9 @@ pub fn dry_exec(mut tmpdir: PathBuf, prefix: &str, rand: usize, suffix: &str) ->
|
||||||
rand::thread_rng().fill(bytes);
|
rand::thread_rng().fill(bytes);
|
||||||
for byte in bytes.iter_mut() {
|
for byte in bytes.iter_mut() {
|
||||||
*byte = match *byte % 62 {
|
*byte = match *byte % 62 {
|
||||||
v @ 0..=9 => (v + '0' as u8),
|
v @ 0..=9 => (v + b'0' as u8),
|
||||||
v @ 10..=35 => (v - 10 + 'a' as u8),
|
v @ 10..=35 => (v - 10 + b'a' as u8),
|
||||||
v @ 36..=61 => (v - 36 + 'A' as u8),
|
v @ 36..=61 => (v - 36 + b'A' as u8),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,13 +189,13 @@ fn write_tabs(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_unwrap!(output.write_all("\t".as_bytes()));
|
safe_unwrap!(output.write_all(b"\t"));
|
||||||
scol += nts;
|
scol += nts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while col > scol {
|
while col > scol {
|
||||||
safe_unwrap!(output.write_all(" ".as_bytes()));
|
safe_unwrap!(output.write_all(b" "));
|
||||||
scol += 1;
|
scol += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ fn unexpand(options: Options) {
|
||||||
for file in options.files.into_iter() {
|
for file in options.files.into_iter() {
|
||||||
let mut fh = open(file);
|
let mut fh = open(file);
|
||||||
|
|
||||||
while match fh.read_until('\n' as u8, &mut buf) {
|
while match fh.read_until(b'\n' as u8, &mut buf) {
|
||||||
Ok(s) => s > 0,
|
Ok(s) => s > 0,
|
||||||
Err(_) => !buf.is_empty(),
|
Err(_) => !buf.is_empty(),
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -99,7 +99,7 @@ impl Uniq {
|
||||||
if self.zero_terminated {
|
if self.zero_terminated {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
'\n' as u8
|
b'\n' as u8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,10 +121,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
const CR: u8 = '\r' as u8;
|
const CR: u8 = b'\r';
|
||||||
const LF: u8 = '\n' as u8;
|
const LF: u8 = b'\n';
|
||||||
const SPACE: u8 = ' ' as u8;
|
const SPACE: u8 = b' ';
|
||||||
const TAB: u8 = '\t' as u8;
|
const TAB: u8 = b'\t';
|
||||||
const SYN: u8 = 0x16 as u8;
|
const SYN: u8 = 0x16 as u8;
|
||||||
const FF: u8 = 0x0C as u8;
|
const FF: u8 = 0x0C as u8;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue