Struct TimeArray

Source
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>

Source

pub fn new(values: [f64; D], unit: TimeUnit) -> Self

Create a new vector of TimeUnit.

Source

pub fn values(&self) -> &[f64; D]

Retrieve values associated with this [TimeSlice].

Source

pub fn values_mut(&mut self) -> &mut [f64; D]

Retrieve the mutable values associated with this [TimeSlice].

Source

pub fn yottasecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::yottasecond.

Source

pub fn zettasecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::zettasecond.

Source

pub fn exasecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::exasecond.

Source

pub fn petasecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::petasecond.

Source

pub fn terasecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::terasecond.

Source

pub fn gigasecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::gigasecond.

Source

pub fn megasecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::megasecond.

Source

pub fn kilosecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::kilosecond.

Source

pub fn hectosecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::hectosecond.

Source

pub fn decasecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::decasecond.

Source

pub fn second(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::second.

Source

pub fn decisecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::decisecond.

Source

pub fn centisecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::centisecond.

Source

pub fn millisecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::millisecond.

Source

pub fn microsecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::microsecond.

Source

pub fn nanosecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::nanosecond.

Source

pub fn picosecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::picosecond.

Source

pub fn femtosecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::femtosecond.

Source

pub fn attosecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::attosecond.

Source

pub fn zeptosecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::zeptosecond.

Source

pub fn yoctosecond(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::yoctosecond.

Source

pub fn second_sidereal(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::second_sidereal.

Source

pub fn day(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::day.

Source

pub fn day_sidereal(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::day_sidereal.

Source

pub fn hour(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::hour.

Source

pub fn hour_sidereal(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::hour_sidereal.

Source

pub fn minute(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::minute.

Source

pub fn shake(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::shake.

Source

pub fn year(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::year.

Source

pub fn year_sidereal(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::year_sidereal.

Source

pub fn year_tropical(values: [f64; D]) -> Self

Create a new Time with units of TimeUnit::year_tropical.

Source

pub fn to_yottasecond(&self) -> Self

Source

pub fn to_zettasecond(&self) -> Self

Source

pub fn to_exasecond(&self) -> Self

Convert to TimeUnit::exasecond.

Source

pub fn to_petasecond(&self) -> Self

Source

pub fn to_terasecond(&self) -> Self

Source

pub fn to_gigasecond(&self) -> Self

Source

pub fn to_megasecond(&self) -> Self

Source

pub fn to_kilosecond(&self) -> Self

Source

pub fn to_hectosecond(&self) -> Self

Source

pub fn to_decasecond(&self) -> Self

Source

pub fn to_second(&self) -> Self

Convert to TimeUnit::second.

Source

pub fn to_decisecond(&self) -> Self

Source

pub fn to_centisecond(&self) -> Self

Source

pub fn to_millisecond(&self) -> Self

Source

pub fn to_microsecond(&self) -> Self

Source

pub fn to_nanosecond(&self) -> Self

Source

pub fn to_picosecond(&self) -> Self

Source

pub fn to_femtosecond(&self) -> Self

Source

pub fn to_attosecond(&self) -> Self

Source

pub fn to_zeptosecond(&self) -> Self

Source

pub fn to_yoctosecond(&self) -> Self

Source

pub fn to_second_sidereal(&self) -> Self

Source

pub fn to_day(&self) -> Self

Convert to TimeUnit::day.

Source

pub fn to_day_sidereal(&self) -> Self

Source

pub fn to_hour(&self) -> Self

Convert to TimeUnit::hour.

Source

pub fn to_hour_sidereal(&self) -> Self

Source

pub fn to_minute(&self) -> Self

Convert to TimeUnit::minute.

Source

pub fn to_shake(&self) -> Self

Convert to TimeUnit::shake.

Source

pub fn to_year(&self) -> Self

Convert to TimeUnit::year.

Source

pub fn to_year_sidereal(&self) -> Self

Source

pub fn to_year_tropical(&self) -> Self

Source

pub fn at(&self, index: usize) -> Time

Methods from Deref<Target = [f64; N]>§

1.57.0 · Source

pub fn as_slice(&self) -> &[T]

Returns a slice containing the entire array. Equivalent to &s[..].

1.57.0 · Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns a mutable slice containing the entire array. Equivalent to &mut s[..].

1.77.0 · Source

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 · Source

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]);
Source

pub fn split_array_ref<const M: usize>(&self) -> (&[T; M], &[T])

🔬This is a nightly-only experimental API. (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, &[]);
}
Source

pub fn split_array_mut<const M: usize>(&mut self) -> (&mut [T; M], &mut [T])

🔬This is a nightly-only experimental API. (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]);
Source

pub fn rsplit_array_ref<const M: usize>(&self) -> (&[T], &[T; M])

🔬This is a nightly-only experimental API. (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]);
}
Source

pub fn rsplit_array_mut<const M: usize>(&mut self) -> (&mut [T], &mut [T; M])

🔬This is a nightly-only experimental API. (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> Add for TimeArray<N>

Source§

type Output = TimeArray<N>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: TimeArray<N>) -> Self

Performs the + operation. Read more
Source§

impl<const N: usize> AddAssign for TimeArray<N>

Source§

fn add_assign(&mut self, rhs: TimeArray<N>)

Performs the += operation. Read more
Source§

impl<const N: usize> Clone for TimeArray<N>

Source§

fn clone(&self) -> TimeArray<N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Debug for TimeArray<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Default for TimeArray<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const N: usize> Deref for TimeArray<N>

Source§

type Target = [f64; N]

The resulting type after dereferencing.
Source§

fn deref(&self) -> &[f64; N]

Dereferences the value.
Source§

impl<const N: usize> DerefMut for TimeArray<N>

Source§

fn deref_mut(&mut self) -> &mut [f64; N]

Mutably dereferences the value.
Source§

impl<const N: usize> Div<f64> for TimeArray<N>

Source§

type Output = TimeArray<N>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl<const N: usize> DivAssign<f64> for TimeArray<N>

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl<const N: usize> FixedSliceQuantity<TimeUnit, f64> for TimeArray<N>

Source§

fn unit(&self) -> TimeUnit

Return unit associated with this quantity
Source§

fn values(&self) -> &[f64]

Return values in quantity
Source§

fn values_mut(&mut self) -> &mut [f64]

Return mutable values in quantity
Source§

fn len(&self) -> usize

Return number of values in quantity
Source§

fn convert(&self, unit: TimeUnit) -> Self

Convert a unit of one UnitType to another of the same type. No validation of base unit is made.
Source§

fn convert_mut(&mut self, unit: TimeUnit)

Mutate current quantity, convering a unit of one 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,

Attempt to convert the unit given in unit to a UnitType. Base unit validation is made here.
Source§

impl<const N: usize> Mul<f64> for TimeArray<N>

Source§

type Output = TimeArray<N>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl<const N: usize> MulAssign<f64> for TimeArray<N>

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl<const N: usize> PartialEq for TimeArray<N>

Source§

fn eq(&self, other: &TimeArray<N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N: usize> Sub for TimeArray<N>

Source§

type Output = TimeArray<N>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: TimeArray<N>) -> Self

Performs the - operation. Read more
Source§

impl<const N: usize> SubAssign for TimeArray<N>

Source§

fn sub_assign(&mut self, rhs: TimeArray<N>)

Performs the -= operation. Read more
Source§

impl<const N: usize> Copy for TimeArray<N>

Source§

impl<const N: usize> StructuralPartialEq for TimeArray<N>

Auto Trait Implementations§

§

impl<const N: usize> Freeze for TimeArray<N>

§

impl<const N: usize> RefUnwindSafe for TimeArray<N>

§

impl<const N: usize> Send for TimeArray<N>

§

impl<const N: usize> Sync for TimeArray<N>

§

impl<const N: usize> Unpin for TimeArray<N>

§

impl<const N: usize> UnwindSafe for TimeArray<N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.