misc
This commit is contained in:
parent
d500f525f7
commit
b3a1e476b2
1 changed files with 15 additions and 15 deletions
30
src/board.rs
30
src/board.rs
|
|
@ -13,13 +13,6 @@ macro_rules! container {
|
||||||
Self(values)
|
Self(values)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[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 {
|
pub const fn get(&self, k: $a) -> &T {
|
||||||
&self.0[k as usize]
|
&self.0[k as usize]
|
||||||
}
|
}
|
||||||
|
|
@ -27,6 +20,13 @@ macro_rules! container {
|
||||||
pub const fn get_mut(&mut self, k: $a) -> &mut T {
|
pub const fn get_mut(&mut self, k: $a) -> &mut T {
|
||||||
&mut self.0[k as usize]
|
&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]);
|
pub struct ByRole<T>(pub(crate) [T; 6]);
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
impl<T> ByRole<T> {
|
impl<T> ByRole<T> {
|
||||||
#[inline]
|
|
||||||
pub fn with<F>(f: F) -> Self
|
|
||||||
where
|
|
||||||
F: FnMut(Role) -> T,
|
|
||||||
{
|
|
||||||
Self(Role::all().map(f))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn new(values: [T; 6]) -> Self {
|
pub const fn new(values: [T; 6]) -> Self {
|
||||||
Self(values)
|
Self(values)
|
||||||
|
|
@ -587,6 +579,14 @@ impl<T> ByRole<T> {
|
||||||
unsafe { std::hint::assert_unchecked(i < 6) };
|
unsafe { std::hint::assert_unchecked(i < 6) };
|
||||||
&mut self.0[i]
|
&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>
|
impl<T> ByRole<T>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue