why these not const

This commit is contained in:
Quaternions 2024-02-21 02:59:20 -08:00
parent c44e5dad96
commit 43a4237c17

View File

@ -10,24 +10,24 @@ impl Time{
pub const ONE_MICROSECOND:Self=Self(1_000);
pub const ONE_NANOSECOND:Self=Self(1);
#[inline]
pub fn from_secs(num:i64)->Self{
pub const fn from_secs(num:i64)->Self{
Self(Self::ONE_SECOND.0*num)
}
#[inline]
pub fn from_millis(num:i64)->Self{
pub const fn from_millis(num:i64)->Self{
Self(Self::ONE_MILLISECOND.0*num)
}
#[inline]
pub fn from_micros(num:i64)->Self{
pub const fn from_micros(num:i64)->Self{
Self(Self::ONE_MICROSECOND.0*num)
}
#[inline]
pub fn from_nanos(num:i64)->Self{
pub const fn from_nanos(num:i64)->Self{
Self(Self::ONE_NANOSECOND.0*num)
}
//should I have checked subtraction? force all time variables to be positive?
#[inline]
pub fn nanos(&self)->i64{
pub const fn nanos(self)->i64{
self.0
}
}