mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-29 23:23:53 +00:00
Replace Default impls that use state with fns
The Default impls for DefaultFormat and LoadFormat were originally called ‘new’, to which Clippy suggested that they be changed. But as these functions change based on what the year is, a function called something other than ‘new’, like ‘load’.
This commit is contained in:
parent
118426309d
commit
c2bb986618
@ -257,16 +257,16 @@ impl TimeFormat {
|
||||
use options::vars;
|
||||
match vars.get(vars::TIME_STYLE) {
|
||||
Some(ref t) if !t.is_empty() => t.clone(),
|
||||
_ => return Ok(TimeFormat::DefaultFormat(DefaultFormat::default()))
|
||||
_ => return Ok(TimeFormat::DefaultFormat(DefaultFormat::load()))
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
if &word == "default" {
|
||||
Ok(TimeFormat::DefaultFormat(DefaultFormat::default()))
|
||||
Ok(TimeFormat::DefaultFormat(DefaultFormat::load()))
|
||||
}
|
||||
else if &word == "iso" {
|
||||
Ok(TimeFormat::ISOFormat(ISOFormat::default()))
|
||||
Ok(TimeFormat::ISOFormat(ISOFormat::load()))
|
||||
}
|
||||
else if &word == "long-iso" {
|
||||
Ok(TimeFormat::LongISO)
|
||||
|
@ -88,8 +88,8 @@ pub struct DefaultFormat {
|
||||
pub date_and_year: DateFormat<'static>,
|
||||
}
|
||||
|
||||
impl Default for DefaultFormat {
|
||||
fn default() -> DefaultFormat {
|
||||
impl DefaultFormat {
|
||||
pub fn load() -> DefaultFormat {
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
let locale = locale::Time::load_user_locale()
|
||||
@ -201,8 +201,8 @@ pub struct ISOFormat {
|
||||
pub current_year: i64,
|
||||
}
|
||||
|
||||
impl Default for ISOFormat {
|
||||
fn default() -> ISOFormat {
|
||||
impl ISOFormat {
|
||||
pub fn load() -> ISOFormat {
|
||||
let current_year = LocalDateTime::now().year();
|
||||
ISOFormat { current_year }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user