1
0
Fork 0
This commit is contained in:
Paul-Nicolas Madelaine 2025-11-05 23:47:00 +01:00
parent d500f525f7
commit b3a1e476b2

View file

@ -13,13 +13,6 @@ macro_rules! container {
Self(values)
}
#[inline]
pub fn with<F>(f: F) -> Self
where
F: FnMut($a) -> T,
{
Self($a::all().map(f))
}
#[inline]
pub const fn get(&self, k: $a) -> &T {
&self.0[k as usize]
}
@ -27,6 +20,13 @@ macro_rules! container {
pub const fn get_mut(&mut self, k: $a) -> &mut T {
&mut self.0[k as usize]
}
#[inline]
pub fn with<F>(f: F) -> Self
where
F: FnMut($a) -> T,
{
Self($a::all().map(f))
}
}
};
}
@ -561,14 +561,6 @@ impl Role {
pub struct ByRole<T>(pub(crate) [T; 6]);
#[allow(unused)]
impl<T> ByRole<T> {
#[inline]
pub fn with<F>(f: F) -> Self
where
F: FnMut(Role) -> T,
{
Self(Role::all().map(f))
}
#[inline]
pub const fn new(values: [T; 6]) -> Self {
Self(values)
@ -587,6 +579,14 @@ impl<T> ByRole<T> {
unsafe { std::hint::assert_unchecked(i < 6) };
&mut self.0[i]
}
#[inline]
pub fn with<F>(f: F) -> Self
where
F: FnMut(Role) -> T,
{
Self(Role::all().map(f))
}
}
impl<T> ByRole<T>