Skip to content

Commit c2bb986

Browse files
committed
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’.
1 parent 1184263 commit c2bb986

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/options/view.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,16 @@ impl TimeFormat {
257257
use options::vars;
258258
match vars.get(vars::TIME_STYLE) {
259259
Some(ref t) if !t.is_empty() => t.clone(),
260-
_ => return Ok(TimeFormat::DefaultFormat(DefaultFormat::default()))
260+
_ => return Ok(TimeFormat::DefaultFormat(DefaultFormat::load()))
261261
}
262262
},
263263
};
264264

265265
if &word == "default" {
266-
Ok(TimeFormat::DefaultFormat(DefaultFormat::default()))
266+
Ok(TimeFormat::DefaultFormat(DefaultFormat::load()))
267267
}
268268
else if &word == "iso" {
269-
Ok(TimeFormat::ISOFormat(ISOFormat::default()))
269+
Ok(TimeFormat::ISOFormat(ISOFormat::load()))
270270
}
271271
else if &word == "long-iso" {
272272
Ok(TimeFormat::LongISO)

src/output/time.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ pub struct DefaultFormat {
8888
pub date_and_year: DateFormat<'static>,
8989
}
9090

91-
impl Default for DefaultFormat {
92-
fn default() -> DefaultFormat {
91+
impl DefaultFormat {
92+
pub fn load() -> DefaultFormat {
9393
use unicode_width::UnicodeWidthStr;
9494

9595
let locale = locale::Time::load_user_locale()
@@ -201,8 +201,8 @@ pub struct ISOFormat {
201201
pub current_year: i64,
202202
}
203203

204-
impl Default for ISOFormat {
205-
fn default() -> ISOFormat {
204+
impl ISOFormat {
205+
pub fn load() -> ISOFormat {
206206
let current_year = LocalDateTime::now().year();
207207
ISOFormat { current_year }
208208
}

0 commit comments

Comments
 (0)