Struct TvmScheduleSolution

Source
pub struct TvmScheduleSolution { /* private fields */ }
Expand description

A record of a Time Value of Money calculation where the rate may vary by period.

It’s the result of calling FutureValueScheduleSolution.tvm_solution or PresentValueScheduleSolution.tvm_solution

Implementations§

Source§

impl TvmScheduleSolution

Source

pub fn calculated_field(&self) -> &TvmVariable

Returns a variant of TvmVariable showing which value was calculated, either the present value or the future value. To test for the enum variant use functions like TvmVariable::is_future_value.

§Examples
let solution = finance_solution::present_value_schedule_solution(&[0.011, 0.012, 0.009], 75_000);
assert!(solution.calculated_field().is_present_value());
Source

pub fn rates(&self) -> &[f64]

Returns the periodic rates that were passed to the function.

Source

pub fn periods(&self) -> u32

Returns the number of periods which was derived from the number of rates passed to the function.

§Examples
let solution = finance_solution::future_value_schedule_solution(&[0.05, 0.07, 0.05], 100_000);
assert_eq!(3, solution.periods());
Source

pub fn present_value(&self) -> f64

Returns the present value which is a calculated value if this TvmSchedule struct is the result of a call to present_value_schedule_solution and otherwise is one of the input values.

Source

pub fn future_value(&self) -> f64

Returns the future value which is a calculated value if this TvmSchedule struct is the result of a call to future_value_schedule_solution and otherwise is one of the input values.

Source

pub fn series(&self) -> TvmSeries

Calculates the value of an investment after each period.

§Examples

Calculate the period-by-period details of a future value calculation. Uses future_value_solution.

// The initial investment is $10,000.12, the interest rate is 1.5% per month, and the
// investment will grow for 24 months using simple compounding.
let solution = finance_solution::future_value_solution(0.015, 24, 10_000.12, false);
dbg!(&solution);

// Calculate the period-by-period details.
let series = solution.series();
dbg!(&series);

// Confirm that we have one entry for the initial value and one entry for each period.
assert_eq!(25, series.len());

// Print the period-by-period numbers in a formatted table.
series.print_table();

// Create a vector with every fourth period.
let filtered_series = series
    .iter()
    .filter(|x| x.period() % 4 == 0)
    .collect::<Vec<_>>();
dbg!(&filtered_series);
assert_eq!(7, filtered_series.len());

Trait Implementations§

Source§

impl Clone for TvmScheduleSolution

Source§

fn clone(&self) -> TvmScheduleSolution

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TvmScheduleSolution

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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