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