Skip to content

Commit

Permalink
Merge pull request #55 from moia-oss/use-missing_const_for_fn
Browse files Browse the repository at this point in the history
use missing_const_for_fn lint and make fns const
  • Loading branch information
rinde authored Mar 14, 2024
2 parents 200a223 + eb66d55 commit dc87f0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ style = "warn"
suspicious = "deny"
todo = "warn"

missing_const_for_fn = "warn"

### Pedantic
pedantic = { level = "warn", priority = -1 }
missing_errors_doc = "allow" # TODO
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Time {
}

#[must_use]
pub fn as_millis(&self) -> i64 {
pub const fn as_millis(&self) -> i64 {
self.0
}

Expand All @@ -205,7 +205,7 @@ impl Time {
/// );
/// ```
#[must_use]
pub fn round_down(&self, step_size: Duration) -> Time {
pub const fn round_down(&self, step_size: Duration) -> Time {
let time_milli = self.as_millis();
let part = time_milli % step_size.as_millis().abs();
Time::millis(time_milli - part)
Expand All @@ -228,7 +228,7 @@ impl Time {
/// );
/// ```
#[must_use]
pub fn round_up(&self, step_size: Duration) -> Time {
pub const fn round_up(&self, step_size: Duration) -> Time {
let time_milli = self.as_millis();
let step_milli = step_size.as_millis().abs();
let part = time_milli % step_milli;
Expand Down Expand Up @@ -264,7 +264,7 @@ impl Time {
}

#[must_use]
pub fn since_epoch(&self) -> Duration {
pub const fn since_epoch(&self) -> Duration {
Duration::millis(self.as_millis())
}
}
Expand Down Expand Up @@ -928,7 +928,7 @@ impl Duration {
}
/// Returns the number of whole milliseconds in the Duration instance.
#[must_use]
pub fn as_millis(&self) -> i64 {
pub const fn as_millis(&self) -> i64 {
self.0
}

Expand Down

0 comments on commit dc87f0f

Please sign in to comment.