Skip to main content

solverforge_solver/builder/context/scalar/
value_source.rs

1use std::fmt;
2
3pub enum ValueSource<S> {
4    Empty,
5    CountableRange {
6        from: usize,
7        to: usize,
8    },
9    SolutionCount {
10        count_fn: fn(&S, usize) -> usize,
11        provider_index: usize,
12    },
13    EntitySlice {
14        values_for_entity: for<'a> fn(&'a S, usize, usize) -> &'a [usize],
15    },
16}
17
18impl<S> Clone for ValueSource<S> {
19    fn clone(&self) -> Self {
20        *self
21    }
22}
23
24impl<S> Copy for ValueSource<S> {}
25
26impl<S> fmt::Debug for ValueSource<S> {
27    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28        match self {
29            Self::Empty => write!(f, "ValueSource::Empty"),
30            Self::CountableRange { from, to } => {
31                write!(f, "ValueSource::CountableRange({from}..{to})")
32            }
33            Self::SolutionCount { provider_index, .. } => {
34                write!(f, "ValueSource::SolutionCount(provider={provider_index})")
35            }
36            Self::EntitySlice { .. } => write!(f, "ValueSource::EntitySlice(..)"),
37        }
38    }
39}