Skip to main content

grip/
contribution_schedule.rs

1// Copyright 2026 Umberto Gotti <umberto.gotti@umbertogotti.dev>
2// Licensed under the MIT License
3// SPDX-License-Identifier: MIT
4
5#[derive(Debug, Clone, Copy, Default)]
6pub struct ContributionSchedule;
7
8impl ContributionSchedule {
9    #[must_use]
10    pub const fn new() -> Self {
11        Self
12    }
13
14    #[must_use]
15    pub fn contribution(&self, is_pure: bool, has_trait_seam: bool, dep_weight: f64) -> f64 {
16        if dep_weight >= 1.0 {
17            return 0.0;
18        }
19        let base = match (is_pure, has_trait_seam) {
20            (true, true) => 1.00,
21            (true, false) => 0.95,
22            (false, true) => 0.85,
23            (false, false) => 0.15,
24        };
25        base * (1.0 - dep_weight)
26    }
27}