You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where I'd like to reuse a buffer type for multiple different DMA operations that require different word sizes and alignments. Basically what I'd like to use as the buffer type is
unionBuffer{u8:[u8;1024],i16:[i16;512],}
Now I'd like to implement WriteTarget twice for this type, with a u8 and i16 word. Unfortunately that doesn't work, since the word type is an associated type of the WriteTarget trait. Maybe it would be better if it was a type parameter instead?
The text was updated successfully, but these errors were encountered:
You could add NewType wrappers around your buffer type and implement WriteTarget on those.
The trait could be changed, too, but this seems to be a rather niche use case.
I'm not sure how I would turn a Box<Buffer> into a Box<NewtypedBuffer> though, at least when Box is some library-provided smart pointer and not alloc::boxed::Box. For example heapless' pool::singleton::Box is generic over the pool it came from, not the pointee, so I don't see a convenient way to use a newtype there.
I have a use case where I'd like to reuse a buffer type for multiple different DMA operations that require different word sizes and alignments. Basically what I'd like to use as the buffer type is
Now I'd like to implement
WriteTarget
twice for this type, with au8
andi16
word. Unfortunately that doesn't work, since the word type is an associated type of theWriteTarget
trait. Maybe it would be better if it was a type parameter instead?The text was updated successfully, but these errors were encountered: