pub struct TimeArray<const N: usize> { /* private fields */ }Expand description
Array storage for a series of values and TimeUnit.
Implementations§
Source§impl<const D: usize> TimeArray<D>
impl<const D: usize> TimeArray<D>
Sourcepub fn values_mut(&mut self) -> &mut [f64; D]
pub fn values_mut(&mut self) -> &mut [f64; D]
Retrieve the mutable values associated with this [TimeSlice].
Sourcepub fn yottasecond(values: [f64; D]) -> Self
pub fn yottasecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::yottasecond.
Sourcepub fn zettasecond(values: [f64; D]) -> Self
pub fn zettasecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::zettasecond.
Sourcepub fn exasecond(values: [f64; D]) -> Self
pub fn exasecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::exasecond.
Sourcepub fn petasecond(values: [f64; D]) -> Self
pub fn petasecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::petasecond.
Sourcepub fn terasecond(values: [f64; D]) -> Self
pub fn terasecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::terasecond.
Sourcepub fn gigasecond(values: [f64; D]) -> Self
pub fn gigasecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::gigasecond.
Sourcepub fn megasecond(values: [f64; D]) -> Self
pub fn megasecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::megasecond.
Sourcepub fn kilosecond(values: [f64; D]) -> Self
pub fn kilosecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::kilosecond.
Sourcepub fn hectosecond(values: [f64; D]) -> Self
pub fn hectosecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::hectosecond.
Sourcepub fn decasecond(values: [f64; D]) -> Self
pub fn decasecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::decasecond.
Sourcepub fn decisecond(values: [f64; D]) -> Self
pub fn decisecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::decisecond.
Sourcepub fn centisecond(values: [f64; D]) -> Self
pub fn centisecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::centisecond.
Sourcepub fn millisecond(values: [f64; D]) -> Self
pub fn millisecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::millisecond.
Sourcepub fn microsecond(values: [f64; D]) -> Self
pub fn microsecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::microsecond.
Sourcepub fn nanosecond(values: [f64; D]) -> Self
pub fn nanosecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::nanosecond.
Sourcepub fn picosecond(values: [f64; D]) -> Self
pub fn picosecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::picosecond.
Sourcepub fn femtosecond(values: [f64; D]) -> Self
pub fn femtosecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::femtosecond.
Sourcepub fn attosecond(values: [f64; D]) -> Self
pub fn attosecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::attosecond.
Sourcepub fn zeptosecond(values: [f64; D]) -> Self
pub fn zeptosecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::zeptosecond.
Sourcepub fn yoctosecond(values: [f64; D]) -> Self
pub fn yoctosecond(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::yoctosecond.
Sourcepub fn second_sidereal(values: [f64; D]) -> Self
pub fn second_sidereal(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::second_sidereal.
Sourcepub fn day_sidereal(values: [f64; D]) -> Self
pub fn day_sidereal(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::day_sidereal.
Sourcepub fn hour_sidereal(values: [f64; D]) -> Self
pub fn hour_sidereal(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::hour_sidereal.
Sourcepub fn year_sidereal(values: [f64; D]) -> Self
pub fn year_sidereal(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::year_sidereal.
Sourcepub fn year_tropical(values: [f64; D]) -> Self
pub fn year_tropical(values: [f64; D]) -> Self
Create a new Time with units of TimeUnit::year_tropical.
Sourcepub fn to_yottasecond(&self) -> Self
pub fn to_yottasecond(&self) -> Self
Convert to TimeUnit::yottasecond.
Sourcepub fn to_zettasecond(&self) -> Self
pub fn to_zettasecond(&self) -> Self
Convert to TimeUnit::zettasecond.
Sourcepub fn to_exasecond(&self) -> Self
pub fn to_exasecond(&self) -> Self
Convert to TimeUnit::exasecond.
Sourcepub fn to_petasecond(&self) -> Self
pub fn to_petasecond(&self) -> Self
Convert to TimeUnit::petasecond.
Sourcepub fn to_terasecond(&self) -> Self
pub fn to_terasecond(&self) -> Self
Convert to TimeUnit::terasecond.
Sourcepub fn to_gigasecond(&self) -> Self
pub fn to_gigasecond(&self) -> Self
Convert to TimeUnit::gigasecond.
Sourcepub fn to_megasecond(&self) -> Self
pub fn to_megasecond(&self) -> Self
Convert to TimeUnit::megasecond.
Sourcepub fn to_kilosecond(&self) -> Self
pub fn to_kilosecond(&self) -> Self
Convert to TimeUnit::kilosecond.
Sourcepub fn to_hectosecond(&self) -> Self
pub fn to_hectosecond(&self) -> Self
Convert to TimeUnit::hectosecond.
Sourcepub fn to_decasecond(&self) -> Self
pub fn to_decasecond(&self) -> Self
Convert to TimeUnit::decasecond.
Sourcepub fn to_second(&self) -> Self
pub fn to_second(&self) -> Self
Convert to TimeUnit::second.
Sourcepub fn to_decisecond(&self) -> Self
pub fn to_decisecond(&self) -> Self
Convert to TimeUnit::decisecond.
Sourcepub fn to_centisecond(&self) -> Self
pub fn to_centisecond(&self) -> Self
Convert to TimeUnit::centisecond.
Sourcepub fn to_millisecond(&self) -> Self
pub fn to_millisecond(&self) -> Self
Convert to TimeUnit::millisecond.
Sourcepub fn to_microsecond(&self) -> Self
pub fn to_microsecond(&self) -> Self
Convert to TimeUnit::microsecond.
Sourcepub fn to_nanosecond(&self) -> Self
pub fn to_nanosecond(&self) -> Self
Convert to TimeUnit::nanosecond.
Sourcepub fn to_picosecond(&self) -> Self
pub fn to_picosecond(&self) -> Self
Convert to TimeUnit::picosecond.
Sourcepub fn to_femtosecond(&self) -> Self
pub fn to_femtosecond(&self) -> Self
Convert to TimeUnit::femtosecond.
Sourcepub fn to_attosecond(&self) -> Self
pub fn to_attosecond(&self) -> Self
Convert to TimeUnit::attosecond.
Sourcepub fn to_zeptosecond(&self) -> Self
pub fn to_zeptosecond(&self) -> Self
Convert to TimeUnit::zeptosecond.
Sourcepub fn to_yoctosecond(&self) -> Self
pub fn to_yoctosecond(&self) -> Self
Convert to TimeUnit::yoctosecond.
Sourcepub fn to_second_sidereal(&self) -> Self
pub fn to_second_sidereal(&self) -> Self
Convert to TimeUnit::second_sidereal.
Sourcepub fn to_day(&self) -> Self
pub fn to_day(&self) -> Self
Convert to TimeUnit::day.
Sourcepub fn to_day_sidereal(&self) -> Self
pub fn to_day_sidereal(&self) -> Self
Convert to TimeUnit::day_sidereal.
Sourcepub fn to_hour(&self) -> Self
pub fn to_hour(&self) -> Self
Convert to TimeUnit::hour.
Sourcepub fn to_hour_sidereal(&self) -> Self
pub fn to_hour_sidereal(&self) -> Self
Convert to TimeUnit::hour_sidereal.
Sourcepub fn to_minute(&self) -> Self
pub fn to_minute(&self) -> Self
Convert to TimeUnit::minute.
Sourcepub fn to_shake(&self) -> Self
pub fn to_shake(&self) -> Self
Convert to TimeUnit::shake.
Sourcepub fn to_year(&self) -> Self
pub fn to_year(&self) -> Self
Convert to TimeUnit::year.
Sourcepub fn to_year_sidereal(&self) -> Self
pub fn to_year_sidereal(&self) -> Self
Convert to TimeUnit::year_sidereal.
Sourcepub fn to_year_tropical(&self) -> Self
pub fn to_year_tropical(&self) -> Self
Convert to TimeUnit::year_tropical.
pub fn at(&self, index: usize) -> Time
Methods from Deref<Target = [f64; N]>§
1.57.0 · Sourcepub fn as_slice(&self) -> &[T]
pub fn as_slice(&self) -> &[T]
Returns a slice containing the entire array. Equivalent to &s[..].
1.57.0 · Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Returns a mutable slice containing the entire array. Equivalent to
&mut s[..].
1.77.0 · Sourcepub fn each_ref(&self) -> [&T; N]
pub fn each_ref(&self) -> [&T; N]
Borrows each element and returns an array of references with the same
size as self.
§Example
let floats = [3.1, 2.7, -1.0];
let float_refs: [&f64; 3] = floats.each_ref();
assert_eq!(float_refs, [&3.1, &2.7, &-1.0]);This method is particularly useful if combined with other methods, like
map. This way, you can avoid moving the original
array if its elements are not Copy.
let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()];
let is_ascii = strings.each_ref().map(|s| s.is_ascii());
assert_eq!(is_ascii, [true, false, true]);
// We can still access the original array: it has not been moved.
assert_eq!(strings.len(), 3);1.77.0 · Sourcepub fn each_mut(&mut self) -> [&mut T; N]
pub fn each_mut(&mut self) -> [&mut T; N]
Borrows each element mutably and returns an array of mutable references
with the same size as self.
§Example
let mut floats = [3.1, 2.7, -1.0];
let float_refs: [&mut f64; 3] = floats.each_mut();
*float_refs[0] = 0.0;
assert_eq!(float_refs, [&mut 0.0, &mut 2.7, &mut -1.0]);
assert_eq!(floats, [0.0, 2.7, -1.0]);Sourcepub fn split_array_ref<const M: usize>(&self) -> (&[T; M], &[T])
🔬This is a nightly-only experimental API. (split_array)
pub fn split_array_ref<const M: usize>(&self) -> (&[T; M], &[T])
split_array)Divides one array reference into two at an index.
The first will contain all indices from [0, M) (excluding
the index M itself) and the second will contain all
indices from [M, N) (excluding the index N itself).
§Panics
Panics if M > N.
§Examples
#![feature(split_array)]
let v = [1, 2, 3, 4, 5, 6];
{
let (left, right) = v.split_array_ref::<0>();
assert_eq!(left, &[]);
assert_eq!(right, &[1, 2, 3, 4, 5, 6]);
}
{
let (left, right) = v.split_array_ref::<2>();
assert_eq!(left, &[1, 2]);
assert_eq!(right, &[3, 4, 5, 6]);
}
{
let (left, right) = v.split_array_ref::<6>();
assert_eq!(left, &[1, 2, 3, 4, 5, 6]);
assert_eq!(right, &[]);
}Sourcepub fn split_array_mut<const M: usize>(&mut self) -> (&mut [T; M], &mut [T])
🔬This is a nightly-only experimental API. (split_array)
pub fn split_array_mut<const M: usize>(&mut self) -> (&mut [T; M], &mut [T])
split_array)Divides one mutable array reference into two at an index.
The first will contain all indices from [0, M) (excluding
the index M itself) and the second will contain all
indices from [M, N) (excluding the index N itself).
§Panics
Panics if M > N.
§Examples
#![feature(split_array)]
let mut v = [1, 0, 3, 0, 5, 6];
let (left, right) = v.split_array_mut::<2>();
assert_eq!(left, &mut [1, 0][..]);
assert_eq!(right, &mut [3, 0, 5, 6]);
left[1] = 2;
right[1] = 4;
assert_eq!(v, [1, 2, 3, 4, 5, 6]);Sourcepub fn rsplit_array_ref<const M: usize>(&self) -> (&[T], &[T; M])
🔬This is a nightly-only experimental API. (split_array)
pub fn rsplit_array_ref<const M: usize>(&self) -> (&[T], &[T; M])
split_array)Divides one array reference into two at an index from the end.
The first will contain all indices from [0, N - M) (excluding
the index N - M itself) and the second will contain all
indices from [N - M, N) (excluding the index N itself).
§Panics
Panics if M > N.
§Examples
#![feature(split_array)]
let v = [1, 2, 3, 4, 5, 6];
{
let (left, right) = v.rsplit_array_ref::<0>();
assert_eq!(left, &[1, 2, 3, 4, 5, 6]);
assert_eq!(right, &[]);
}
{
let (left, right) = v.rsplit_array_ref::<2>();
assert_eq!(left, &[1, 2, 3, 4]);
assert_eq!(right, &[5, 6]);
}
{
let (left, right) = v.rsplit_array_ref::<6>();
assert_eq!(left, &[]);
assert_eq!(right, &[1, 2, 3, 4, 5, 6]);
}Sourcepub fn rsplit_array_mut<const M: usize>(&mut self) -> (&mut [T], &mut [T; M])
🔬This is a nightly-only experimental API. (split_array)
pub fn rsplit_array_mut<const M: usize>(&mut self) -> (&mut [T], &mut [T; M])
split_array)Divides one mutable array reference into two at an index from the end.
The first will contain all indices from [0, N - M) (excluding
the index N - M itself) and the second will contain all
indices from [N - M, N) (excluding the index N itself).
§Panics
Panics if M > N.
§Examples
#![feature(split_array)]
let mut v = [1, 0, 3, 0, 5, 6];
let (left, right) = v.rsplit_array_mut::<4>();
assert_eq!(left, &mut [1, 0]);
assert_eq!(right, &mut [3, 0, 5, 6][..]);
left[1] = 2;
right[1] = 4;
assert_eq!(v, [1, 2, 3, 4, 5, 6]);Trait Implementations§
Source§impl<const N: usize> AddAssign for TimeArray<N>
impl<const N: usize> AddAssign for TimeArray<N>
Source§fn add_assign(&mut self, rhs: TimeArray<N>)
fn add_assign(&mut self, rhs: TimeArray<N>)
+= operation. Read moreSource§impl<const N: usize> DivAssign<f64> for TimeArray<N>
impl<const N: usize> DivAssign<f64> for TimeArray<N>
Source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
/= operation. Read moreSource§impl<const N: usize> FixedSliceQuantity<TimeUnit, f64> for TimeArray<N>
impl<const N: usize> FixedSliceQuantity<TimeUnit, f64> for TimeArray<N>
Source§fn values_mut(&mut self) -> &mut [f64]
fn values_mut(&mut self) -> &mut [f64]
Source§fn convert(&self, unit: TimeUnit) -> Self
fn convert(&self, unit: TimeUnit) -> Self
UnitType to another of the same type. No validation of base unit is made.Source§fn convert_mut(&mut self, unit: TimeUnit)
fn convert_mut(&mut self, unit: TimeUnit)
UnitType to another of the same type. No validation of base unit is made.Source§fn try_convert(&self, unit: Units) -> Result<Self, RuntimeUnitError>where
Self: Sized,
fn try_convert(&self, unit: Units) -> Result<Self, RuntimeUnitError>where
Self: Sized,
unit to a UnitType. Base unit validation is made here.Source§impl<const N: usize> MulAssign<f64> for TimeArray<N>
impl<const N: usize> MulAssign<f64> for TimeArray<N>
Source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
*= operation. Read moreSource§impl<const N: usize> SubAssign for TimeArray<N>
impl<const N: usize> SubAssign for TimeArray<N>
Source§fn sub_assign(&mut self, rhs: TimeArray<N>)
fn sub_assign(&mut self, rhs: TimeArray<N>)
-= operation. Read more