type_const/
consts.rs

1//! A small collection of useful consts.
2
3use std::mem::MaybeUninit;
4
5use crate::Const;
6
7/// Evaluates to [`Some(C::VALUE)`](Option)
8pub struct IntoSome<C>(C);
9impl<C: Const> Const for IntoSome<C> {
10    type Type = Option<C::Type>;
11    const VALUE: Self::Type = Some(C::VALUE);
12}
13
14/// Evaluates to [`MaybeUninit::<T>::uninit()`](MaybeUninit)
15pub struct UninitOf<T>(T);
16impl<T> Const for UninitOf<T> {
17    type Type = MaybeUninit<T>;
18    const VALUE: Self::Type = MaybeUninit::uninit();
19}
20
21/// Evaluates to [`MaybeUninit::new(C::VALUE)`](MaybeUninit)
22pub struct IntoInit<C>(C);
23impl<C: Const> Const for IntoInit<C> {
24    type Type = MaybeUninit<C::Type>;
25    const VALUE: Self::Type = MaybeUninit::new(C::VALUE);
26}