【发布时间】:2021-02-25 10:05:59
【问题描述】:
我决定使用更强大的 clippy 版本来为版本更改做好准备。我期待一些误报,但我不确定这个。我得到了以下结构,clippy 告诉我每个函数都应该是 const。 (clippy::missing_const_for_fn)
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ScheduleFields {
years: Years,
days_of_week: DaysOfWeek,
months: Months,
days_of_month: DaysOfMonth,
hours: Hours,
minutes: Minutes,
seconds: Seconds,
}
impl ScheduleFields {
// Constructor
pub fn new(
seconds: Seconds,
minutes: Minutes,
hours: Hours,
days_of_month: DaysOfMonth,
months: Months,
days_of_week: DaysOfWeek,
years: Years,
) -> ScheduleFields {
ScheduleFields {
years,
days_of_week,
months,
days_of_month,
hours,
minutes,
seconds,
}
}
// Getters
pub fn years(&self) -> &Years { &self.years }
pub fn months(&self) -> &Months { &self.months }
pub fn days_of_month(&self) -> &DaysOfMonth { &self.days_of_month }
pub fn days_of_week(&self) -> &DaysOfWeek { &self.days_of_week }
pub fn hours(&self) -> &Hours { &self.hours }
pub fn minutes(&self) -> &Minutes { &self.minutes }
pub fn seconds(&self) -> &Seconds { &self.seconds }
}
【问题讨论】:
标签: rust rust-clippy