mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 07:12:44 +00:00
Merge pull request #4281 from cakebaker/default_trait_access
clippy: use type name instead of Default::default
This commit is contained in:
commit
f12202e39c
10 changed files with 20 additions and 20 deletions
|
@ -491,8 +491,8 @@ impl<'a> Output<'a> {
|
||||||
// These objects are counters, initialized to zero. After each
|
// These objects are counters, initialized to zero. After each
|
||||||
// iteration of the main loop, each will be incremented by the
|
// iteration of the main loop, each will be incremented by the
|
||||||
// number of blocks read and written, respectively.
|
// number of blocks read and written, respectively.
|
||||||
let mut rstat = Default::default();
|
let mut rstat = ReadStat::default();
|
||||||
let mut wstat = Default::default();
|
let mut wstat = WriteStat::default();
|
||||||
|
|
||||||
// The time at which the main loop starts executing.
|
// The time at which the main loop starts executing.
|
||||||
//
|
//
|
||||||
|
|
|
@ -105,11 +105,11 @@ impl Default for Options {
|
||||||
Self {
|
Self {
|
||||||
show_local_fs: Default::default(),
|
show_local_fs: Default::default(),
|
||||||
show_all_fs: Default::default(),
|
show_all_fs: Default::default(),
|
||||||
block_size: Default::default(),
|
block_size: BlockSize::default(),
|
||||||
human_readable: Default::default(),
|
human_readable: Option::default(),
|
||||||
header_mode: Default::default(),
|
header_mode: HeaderMode::default(),
|
||||||
include: Default::default(),
|
include: Option::default(),
|
||||||
exclude: Default::default(),
|
exclude: Option::default(),
|
||||||
sync: Default::default(),
|
sync: Default::default(),
|
||||||
show_total: Default::default(),
|
show_total: Default::default(),
|
||||||
columns: vec![
|
columns: vec![
|
||||||
|
|
|
@ -149,7 +149,7 @@ impl Mode {
|
||||||
Ok(Self::FirstLines(n))
|
Ok(Self::FirstLines(n))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(Default::default())
|
Ok(Self::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -604,7 +604,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let key1 = parse_field_number_option(matches.get_one::<String>("1").map(|s| s.as_str()))?;
|
let key1 = parse_field_number_option(matches.get_one::<String>("1").map(|s| s.as_str()))?;
|
||||||
let key2 = parse_field_number_option(matches.get_one::<String>("2").map(|s| s.as_str()))?;
|
let key2 = parse_field_number_option(matches.get_one::<String>("2").map(|s| s.as_str()))?;
|
||||||
|
|
||||||
let mut settings: Settings = Default::default();
|
let mut settings = Settings::default();
|
||||||
|
|
||||||
let v_values = matches.get_many::<String>("v");
|
let v_values = matches.get_many::<String>("v");
|
||||||
if v_values.is_some() {
|
if v_values.is_some() {
|
||||||
|
|
|
@ -227,7 +227,7 @@ impl Display for PtxError {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_config(matches: &clap::ArgMatches) -> UResult<Config> {
|
fn get_config(matches: &clap::ArgMatches) -> UResult<Config> {
|
||||||
let mut config: Config = Default::default();
|
let mut config = Config::default();
|
||||||
let err_msg = "parsing options failed";
|
let err_msg = "parsing options failed";
|
||||||
if matches.get_flag(options::TRADITIONAL) {
|
if matches.get_flag(options::TRADITIONAL) {
|
||||||
config.gnu_ext = false;
|
config.gnu_ext = false;
|
||||||
|
|
|
@ -676,7 +676,7 @@ impl<'a> Line<'a> {
|
||||||
|| settings
|
|| settings
|
||||||
.selectors
|
.selectors
|
||||||
.last()
|
.last()
|
||||||
.map_or(true, |selector| selector != &Default::default()))
|
.map_or(true, |selector| selector != &FieldSelector::default()))
|
||||||
{
|
{
|
||||||
// A last resort comparator is in use, underline the whole line.
|
// A last resort comparator is in use, underline the whole line.
|
||||||
if self.line.is_empty() {
|
if self.line.is_empty() {
|
||||||
|
@ -1049,7 +1049,7 @@ fn make_sort_mode_arg(mode: &'static str, short: char, help: &'static str) -> Ar
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let args = args.collect_ignore();
|
let args = args.collect_ignore();
|
||||||
let mut settings: GlobalSettings = Default::default();
|
let mut settings = GlobalSettings::default();
|
||||||
|
|
||||||
let matches = match uu_app().try_get_matches_from(args) {
|
let matches = match uu_app().try_get_matches_from(args) {
|
||||||
Ok(t) => t,
|
Ok(t) => t,
|
||||||
|
@ -1761,7 +1761,7 @@ fn get_rand_string() -> [u8; 16] {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_hash<T: Hash>(t: &T) -> u64 {
|
fn get_hash<T: Hash>(t: &T) -> u64 {
|
||||||
let mut s: FnvHasher = Default::default();
|
let mut s = FnvHasher::default();
|
||||||
t.hash(&mut s);
|
t.hash(&mut s);
|
||||||
s.finish()
|
s.finish()
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl TmpDirWrapper {
|
||||||
parent_path: path,
|
parent_path: path,
|
||||||
size: 0,
|
size: 0,
|
||||||
temp_dir: None,
|
temp_dir: None,
|
||||||
lock: Default::default(),
|
lock: Arc::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,7 @@ pub fn get_primitive_dec(
|
||||||
last_dec_place: usize,
|
last_dec_place: usize,
|
||||||
sci_mode: Option<bool>,
|
sci_mode: Option<bool>,
|
||||||
) -> FormatPrimitive {
|
) -> FormatPrimitive {
|
||||||
let mut f: FormatPrimitive = Default::default();
|
let mut f = FormatPrimitive::default();
|
||||||
|
|
||||||
// add negative sign section
|
// add negative sign section
|
||||||
if initial_prefix.sign == -1 {
|
if initial_prefix.sign == -1 {
|
||||||
|
|
|
@ -121,7 +121,7 @@ impl Intf {
|
||||||
// get a FormatPrimitive of the maximum value for the field char
|
// get a FormatPrimitive of the maximum value for the field char
|
||||||
// and given sign
|
// and given sign
|
||||||
fn get_max(field_char: char, sign: i8) -> FormatPrimitive {
|
fn get_max(field_char: char, sign: i8) -> FormatPrimitive {
|
||||||
let mut fmt_primitive: FormatPrimitive = Default::default();
|
let mut fmt_primitive = FormatPrimitive::default();
|
||||||
fmt_primitive.pre_decimal = Some(String::from(match field_char {
|
fmt_primitive.pre_decimal = Some(String::from(match field_char {
|
||||||
'd' | 'i' => match sign {
|
'd' | 'i' => match sign {
|
||||||
1 => "9223372036854775807",
|
1 => "9223372036854775807",
|
||||||
|
@ -160,7 +160,7 @@ impl Intf {
|
||||||
match field_char {
|
match field_char {
|
||||||
'i' | 'd' => match i64::from_str_radix(segment, radix_in as u32) {
|
'i' | 'd' => match i64::from_str_radix(segment, radix_in as u32) {
|
||||||
Ok(i) => {
|
Ok(i) => {
|
||||||
let mut fmt_prim: FormatPrimitive = Default::default();
|
let mut fmt_prim = FormatPrimitive::default();
|
||||||
if sign == -1 {
|
if sign == -1 {
|
||||||
fmt_prim.prefix = Some(String::from("-"));
|
fmt_prim.prefix = Some(String::from("-"));
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ impl Intf {
|
||||||
},
|
},
|
||||||
_ => match u64::from_str_radix(segment, radix_in as u32) {
|
_ => match u64::from_str_radix(segment, radix_in as u32) {
|
||||||
Ok(u) => {
|
Ok(u) => {
|
||||||
let mut fmt_prim: FormatPrimitive = Default::default();
|
let mut fmt_prim = FormatPrimitive::default();
|
||||||
let u_f = if sign == -1 { u64::MAX - (u - 1) } else { u };
|
let u_f = if sign == -1 { u64::MAX - (u - 1) } else { u };
|
||||||
fmt_prim.pre_decimal = Some(match field_char {
|
fmt_prim.pre_decimal = Some(match field_char {
|
||||||
'X' => format!("{:X}", u_f),
|
'X' => format!("{:X}", u_f),
|
||||||
|
@ -235,7 +235,7 @@ impl Formatter for Intf {
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// otherwise just do a straight string copy.
|
// otherwise just do a straight string copy.
|
||||||
let mut fmt_prim: FormatPrimitive = Default::default();
|
let mut fmt_prim = FormatPrimitive::default();
|
||||||
|
|
||||||
// this is here and not earlier because
|
// this is here and not earlier because
|
||||||
// zero doesn't get a sign, and conv_from_segment
|
// zero doesn't get a sign, and conv_from_segment
|
||||||
|
|
|
@ -218,7 +218,7 @@ pub fn num_format(field: &FormatField, in_str_opt: Option<&String>) -> Option<St
|
||||||
// if we can get an assumed value from looking at the first
|
// if we can get an assumed value from looking at the first
|
||||||
// few characters, use that value to create the FormatPrimitive
|
// few characters, use that value to create the FormatPrimitive
|
||||||
if let Some(provided_num) = get_provided(in_str_opt) {
|
if let Some(provided_num) = get_provided(in_str_opt) {
|
||||||
let mut tmp : FormatPrimitive = Default::default();
|
let mut tmp = FormatPrimitive::default();
|
||||||
match field_char {
|
match field_char {
|
||||||
'u' | 'i' | 'd' => {
|
'u' | 'i' | 'd' => {
|
||||||
tmp.pre_decimal = Some(
|
tmp.pre_decimal = Some(
|
||||||
|
|
Loading…
Reference in a new issue