pub fn sln_into<T: FloatLike>(
slice: &mut [DepreciationPeriod<T>],
cost: T,
salvage: T,
)
Expand description
Straight Line Depreciation (SLN) Into
Calculates the depreciation schedule for an asset using the straight-line method, mutating a
“slice” of DepreciationPeriod
.
§Arguments
slice
- A mutable slice ofDepreciationPeriod
instances to be filled with the depreciation schedule.
Warning: The length of the slice should be as long as the life as the asset or there will be unexpected behavior.
cost
- The initial cost of the assetsalvage
- The estimated salvage value of the asset at the end of its useful life
§Examples
- $10,000 asset, $1,000 salvage value, 5 year life
use rust_finprim::amort_dep_tax::{DepreciationPeriod, sln_into};
let life = 5;
let cost = 10_000.0;
let salvage = 1_000.0;
let mut schedule = vec![DepreciationPeriod::default(); life as usize];
sln_into(&mut schedule, cost, salvage);