Arrays should impl the bitwise operations
Open
Nobody has claimed this yet.
A-arithmetic
A-array
A-operator
T-lang
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
I have a couple [u8; 8]s that I'd like to xor with each other. Unfortunately this doesn't work:
let x = [0u8; 8];
let y = [1u8; 8];
let z = x ^ y;
I think it should, since this has pretty clear semantics. More generally I think it would make sense to have an impl:
impl<const N: usize, A, B> BitXor<[B; N]> for [A; N]
where
A: BitXor<B>,
{
type Output = [<A as BitXor<B>>::Output; N];
fn bitxor(self, rhs: [B; N]) -> Self::Output {
...
}
}
And similar for BitAnd and BitOr.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points. Start from the proposed generic BitXor implementation and the requested BitAnd and BitOr counterparts; done means resolving whether same-length arrays should support these element-wise operations and documenting or implementing the agreed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100