rust/landgen/src/lib.rs
author unc0rr
Wed, 31 Oct 2018 23:36:05 +0100
changeset 14051 8a0d69c16cad
parent 14027 cef0c685fda8
child 14054 3185fb34f3b5
permissions -rw-r--r--
Implement OutlinePoints for land generators, some ground work for template based landgen
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14026
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
     1
mod template_based;
13908
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
     2
13938
1fa905aa4cdb move point struct into integral-geometry and use it to refactor a bit
alfadur
parents: 13908
diff changeset
     3
extern crate integral_geometry;
14026
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
     4
extern crate land2d;
14051
8a0d69c16cad Implement OutlinePoints for land generators, some ground work for template based landgen
unc0rr
parents: 14027
diff changeset
     5
extern crate itertools;
14026
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
     6
14027
cef0c685fda8 make useful stuff public
alfadur
parents: 14026
diff changeset
     7
pub struct LandGenerationParameters<T> {
14026
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
     8
    zero: T,
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
     9
    basic: T,
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
    10
}
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
    11
14027
cef0c685fda8 make useful stuff public
alfadur
parents: 14026
diff changeset
    12
pub trait LandGenerator {
14026
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
    13
    fn generate_land<T: Copy + PartialEq, I: Iterator<Item = u32>>(
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
    14
        &self,
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
    15
        parameters: LandGenerationParameters<T>,
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
    16
        random_numbers: &mut I,
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
    17
    ) -> land2d::Land2D<T>;
3b3d97ed2286 Start land generators implementation
unc0rr
parents: 13938
diff changeset
    18
}
13938
1fa905aa4cdb move point struct into integral-geometry and use it to refactor a bit
alfadur
parents: 13908
diff changeset
    19
13908
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    20
#[cfg(test)]
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    21
mod tests {
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    22
    #[test]
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    23
    fn it_works() {
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    24
        assert_eq!(2 + 2, 4);
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    25
    }
9a1f1e8170f2 Start work on landgen rust lib
unc0rr
parents:
diff changeset
    26
}