File tree 12 files changed +69
-27
lines changed 12 files changed +69
-27
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " fern_sim"
3
3
version = " 0.1.0"
4
+ edition = " 2018"
4
5
authors = [
" You <[email protected] >" ]
5
6
license = " MIT"
6
7
homepage = " https://fernsim.example.com/"
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
//! Simulate the growth of ferns, from the level of
2
2
//! individual cells on up.
3
3
4
- pub mod cells;
4
+ #![ warn( rust_2018_idioms) ]
5
+ #![ allow( elided_lifetimes_in_paths) ]
6
+
5
7
pub mod plant_structures;
6
8
pub mod simulation;
7
9
pub mod spores;
Original file line number Diff line number Diff line change 2
2
//! Simulation of individual leaves (for the formation of leaves, see `stem`).
3
3
4
4
pub struct Leaf {
5
- x : bool
5
+ pub x : bool
6
6
}
Original file line number Diff line number Diff line change @@ -43,3 +43,17 @@ impl Fern {
43
43
self . stems . iter ( ) . all ( |s| !s. furled )
44
44
}
45
45
}
46
+
47
+ /// Create and return a [`VascularPath`] which represents the path of
48
+ /// nutrients from the given [`Root`][r] to the given [`Leaf`](leaves::Leaf).
49
+ ///
50
+ /// [r]: roots::Root
51
+ pub fn trace_path ( leaf : & leaves:: Leaf , root : & roots:: Root ) -> VascularPath {
52
+ VascularPath { from : leaf. x , to : root. x }
53
+ }
54
+
55
+ #[ doc( alias = "route" ) ]
56
+ pub struct VascularPath {
57
+ pub from : bool ,
58
+ pub to : bool ,
59
+ }
Original file line number Diff line number Diff line change 1
1
#![ allow( dead_code) ]
2
2
3
3
pub struct Root {
4
- x : bool
4
+ pub x : bool
5
5
}
6
6
7
7
pub type RootSet = Vec < Root > ;
Original file line number Diff line number Diff line change 3
3
//! the feathery leaf structure that's the most immediately recognizable
4
4
//! property of ferns.
5
5
6
+ // in plant_structures/stems.rs
7
+ pub mod xylem;
8
+ pub mod phloem;
9
+
6
10
pub struct Stem {
7
11
pub furled : bool
8
12
}
Original file line number Diff line number Diff line change
1
+ //! Structures for distributing the products of photosynthesis.
2
+
3
+ /// Tissue for translocating sucrose and other photosynthesis products.
4
+ pub struct Phloem {
5
+ pub flow_rate : f32 ,
6
+ }
Original file line number Diff line number Diff line change
1
+ //! Structures for bringing nutrients from roots up to other parts of the plant.
2
+
3
+ /// Vascular tissue for transporting water and nutrients from the roots.
4
+ pub struct Xylem {
5
+ pub flow_rate : f32 ,
6
+ }
Original file line number Diff line number Diff line change 4
4
5
5
use std:: fs:: File ;
6
6
use std:: time:: Duration ;
7
- use plant_structures:: { Fern , FernType } ;
7
+ use crate :: plant_structures:: { Fern , FernType } ;
8
8
9
9
/// The simulated universe.
10
10
pub struct Terrarium {
Original file line number Diff line number Diff line change 2
2
3
3
//! Fern reproduction.
4
4
5
- use cells:: Cell ;
5
+ use cells:: { Cell , Gene } ;
6
6
7
7
/// A cell made by an adult fern. It disperses on the wind as part of
8
8
/// the fern life cycle. A spore grows into a prothallus -- a whole
9
- /// separate organism, up to 5mm across -- which produces a zygote,
10
- /// which becomes a new fern. (Plant sex is complicated.)
9
+ /// separate organism, up to 5mm across -- which produces the zygote
10
+ /// that grows into a new fern. (Plant sex is complicated.)
11
11
pub struct Spore {
12
- x : bool
13
- }
14
-
15
- /// A compartment, usually on the bottom of a leaf, where spores form.
16
- pub struct Sporangium {
17
- x : bool
12
+ size : f64
18
13
}
19
14
20
15
/// Simulate the production of a spore by meiosis.
21
16
pub fn produce_spore ( factory : & mut Sporangium ) -> Spore {
22
- Spore { x : false }
17
+ Spore { size : 1.0 }
18
+ }
19
+
20
+ /// Extract the genes in a particular spore.
21
+ pub ( crate ) fn genes ( spore : & Spore ) -> Vec < Gene > {
22
+ todo ! ( )
23
23
}
24
24
25
25
/// Mix genes to prepare for meiosis (part of interphase).
26
26
fn recombine ( parent : & mut Cell ) {
27
+ todo ! ( )
27
28
}
28
29
30
+ pub struct Sporangium ;
31
+
32
+ mod cells {
33
+ //! The simulation of biological cells, which is as low-level as we go.
34
+
35
+ pub struct Cell {
36
+ x : f64 ,
37
+ y : f64
38
+ }
39
+
40
+ impl Cell {
41
+ pub fn distance_from_origin ( & self ) -> f64 {
42
+ f64:: hypot ( self . x , self . y )
43
+ }
44
+ }
45
+
46
+ pub struct Gene ;
47
+ }
Original file line number Diff line number Diff line change 1
1
// tests/unfurl.rs - Fiddleheads unfurl in sunlight
2
2
3
- extern crate fern_sim;
3
+ #![ warn( rust_2018_idioms) ]
4
+ #![ allow( elided_lifetimes_in_paths) ]
5
+
4
6
use fern_sim:: Terrarium ;
5
7
use std:: time:: Duration ;
6
8
You can’t perform that action at this time.
0 commit comments