Open VisualEhrmanntraut opened 2 years ago
So, I want this as well, but I wonder if it's even possible. I tried:
impl moduler_bitfield::Specifier for [B5; 5] {
// ...
}
only to get
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> src/main.rs:66:1
|
66 | impl Specifier for [B5; 5]
| ^^^^^^^^^^^^^^^^^^^-------
| | |
| | this is not defined in the current crate because arrays are always foreign
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead
For more information about this error, try `rustc --explain E0117`.
which seems like you can't add a trait to an array?
So, I want this as well, but I wonder if it's even possible.
I tried:
impl moduler_bitfield::Specifier for [B5; 5] { // ... }
only to get
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types --> src/main.rs:66:1 | 66 | impl Specifier for [B5; 5] | ^^^^^^^^^^^^^^^^^^^------- | | | | | this is not defined in the current crate because arrays are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead For more information about this error, try `rustc --explain E0117`.
which seems like you can't add a trait to an array?
What it means is that you'll have to implement the trait inside of the modular_bitfield crate I assume to add such array support that we will have to add to the the trait implementation generation new logic for arrays, perhaps by parsing the array syntax, seeing its element type and count, then handling data representation accordingly?
Any Updates to this issue?
Currently, the following is not supported:
It will complain with the error below: