1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use necsim_core_bond::{NonNegativeF64, PositiveF64};

use crate::{
    cogs::{Habitat, LineageStore, MathsCore, RngCore},
    landscape::{IndexedLocation, Location},
    lineage::GlobalLineageReference,
    simulation::partial::emigration_exit::PartialSimulation,
};

#[allow(
    clippy::inline_always,
    clippy::inline_fn_without_body,
    clippy::too_many_arguments
)]
#[allow(clippy::no_effect_underscore_binding)]
#[contract_trait]
pub trait EmigrationExit<M: MathsCore, H: Habitat<M>, G: RngCore<M>, S: LineageStore<M, H>>:
    crate::cogs::Backup + core::fmt::Debug
{
    #[must_use]
    #[debug_ensures(match &ret {
        Some((
            ret_lineage_reference,
            ret_dispersal_origin,
            ret_dispersal_target,
            ret_prior_time,
            ret_event_time,
        )) => {
            ret_lineage_reference == &old(global_reference.clone()) &&
            ret_dispersal_origin == &old(dispersal_origin.clone()) &&
            ret_dispersal_target == &old(dispersal_target.clone()) &&
            ret_prior_time == &old(prior_time) &&
            ret_event_time == &old(event_time)
        },
        None => true,
    }, "if ret is Some, it returns the input parameters unchanged")]
    fn optionally_emigrate(
        &mut self,
        global_reference: GlobalLineageReference,
        dispersal_origin: IndexedLocation,
        dispersal_target: Location,
        prior_time: NonNegativeF64,
        event_time: PositiveF64,
        simulation: &mut PartialSimulation<M, H, G, S>,
        rng: &mut G,
    ) -> Option<(
        GlobalLineageReference,
        IndexedLocation,
        Location,
        NonNegativeF64,
        PositiveF64,
    )>;
}