fern_sim/
lib.rs

1//! Fern allows you to manipulate ferns.
2//! It's a sample crate to testing purpose.
3//! 
4//! ```js
5//! console.log(1 === 1);
6//! ```
7#[derive(Debug)]
8pub struct Fern {
9    pub size: f64,
10    pub growth_rate: f64,
11}
12
13impl Fern {
14    /// Simulate a fern growing for one day.
15    pub fn grow(&mut self) {
16        self.size *= 1.0 + self.growth_rate;
17    }
18}
19
20/// Run a fern simulation for some number of days.
21pub fn run_simulation(fern: &mut Fern, days: usize) {
22    for _ in 0..days {
23        fern.grow();
24    }
25}