Skip to main content

ROI

Trait ROI 

Source
pub trait ROI {
    // Required method
    fn h_return_on_investment(&self, new_value: f64) -> f64;
}
Expand description

This trait calculates the return on investment (ROI) given a new value. The ROI is calculated as ((new_value - original_value) / original_value) * 100, where original_value is the value of the investment before the change. The function will return the ROI as a percentage. For example, if the original value of an investment is 100 and the new value is 150, the ROI would be ((150 - 100) / 100) * 100 = 50%, indicating a 50% return on the original investment. Example usage: let original_value = 100.0; let new_value = 150.0; let roi = original_value.h_return_on_investment(new_value); The result will be 50.0, because the return on investment is ((150 - 100) / 100) * 100 = 50%.

Required Methods§

Source

fn h_return_on_investment(&self, new_value: f64) -> f64

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> ROI for T
where T: Copy + Into<f64>,