cometsfactory 0.0.3

Comet factory — classify, build and catalogue comets of any type: short-period, long-period, Halley-type, sungrazer, interstellar, main-belt comet, centaur-transition, and extinct.
Documentation
use cometsfactory::types::extinct::DormancyState;
use cometsfactory::types::sungrazer::SungrazerGroup;
use cometsfactory::types::*;
use cometsfactory::utils::io;

fn main() {
    let comets: Vec<GeneratedComet> = vec![
        GeneratedComet::ShortPeriod(
            ShortPeriod::new(500.0, 3.5, 0.6)
                .with_density(600.0)
                .with_inclination(10.0)
                .with_active_fraction(0.03),
        ),
        GeneratedComet::LongPeriod(
            LongPeriod::new(3000.0, 30000.0, 0.9999).with_dynamically_new(true),
        ),
        GeneratedComet::HalleyType(HalleyType::new(5500.0, 18.0, 0.97).with_inclination(162.0)),
        GeneratedComet::Sungrazer(
            Sungrazer::new(30.0, 150.0, 0.99999).with_group(SungrazerGroup::Kreutz),
        ),
        GeneratedComet::Interstellar(Interstellar::new(200.0, 26.0, 2.0).with_density(400.0)),
        GeneratedComet::MainBeltComet(MainBeltComet::new(400.0, 3.1, 0.16).with_ice_fraction(0.04)),
        GeneratedComet::CentaurTransition(
            CentaurTransition::new(8000.0, 12.0, 0.35).with_co_driven(true),
        ),
        GeneratedComet::Extinct(
            Extinct::new(600.0, 3.0, 0.5)
                .with_mantle_thickness(5.0)
                .with_residual_ice(0.02),
        ),
    ];

    let mut sp_count = 0u32;
    let mut lp_count = 0u32;
    let mut ht_count = 0u32;
    let mut sg_count = 0u32;
    let mut is_count = 0u32;
    let mut mb_count = 0u32;
    let mut ct_count = 0u32;
    let mut ex_count = 0u32;

    for comet in &comets {
        let line = io::summary_line(comet);
        assert!(!line.is_empty());
        match comet {
            GeneratedComet::ShortPeriod(c) => {
                sp_count += 1;
                assert!(c.mass() > 0.0);
                assert!(c.perihelion() < c.semi_major_axis);
            }
            GeneratedComet::LongPeriod(c) => {
                lp_count += 1;
                assert!(c.orbital_period_years() > 200.0);
            }
            GeneratedComet::HalleyType(c) => {
                ht_count += 1;
                assert!(c.is_retrograde);
            }
            GeneratedComet::Sungrazer(c) => {
                sg_count += 1;
                assert!(c.perihelion_temperature() > 500.0);
            }
            GeneratedComet::Interstellar(c) => {
                is_count += 1;
                assert!(c.is_unbound());
            }
            GeneratedComet::MainBeltComet(c) => {
                mb_count += 1;
                assert!(c.ice_mass() > 0.0);
            }
            GeneratedComet::CentaurTransition(c) => {
                ct_count += 1;
                assert!(c.dynamical_lifetime_myr() > 0.0);
            }
            GeneratedComet::Extinct(c) => {
                ex_count += 1;
                assert_eq!(c.state, DormancyState::Dormant);
            }
        }
    }

    let total =
        sp_count + lp_count + ht_count + sg_count + is_count + mb_count + ct_count + ex_count;
    assert_eq!(total, 8);
}