1use std::ops::Deref;
2
3#[derive(Debug)]
4pub(crate) struct Guard;
5
6#[derive(Debug)]
8#[repr(transparent)]
9pub struct Choice<'guard, T> {
10 value: T,
11 _guard: std::marker::PhantomData<&'guard Guard>,
12}
13
14impl<'a, T> Deref for Choice<'a, T> {
16 type Target = T;
17
18 fn deref(&self) -> &Self::Target {
19 &self.value
20 }
21}
22
23impl<'guard, T> Choice<'guard, T> {
24 pub(crate) fn with_guard(value: T, _guard: &'guard Guard) -> Choice<'guard, T> {
25 Choice {
26 value,
27 _guard: std::marker::PhantomData,
28 }
29 }
30
31 pub(crate) fn into_inner(self) -> T {
32 self.value
33 }
34}
35
36pub(crate) fn to_values<T>(choices: Vec<Choice<'_, T>>) -> Vec<T> {
37 choices.into_iter().map(Choice::into_inner).collect()
41}