We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReadTarget allows implement ReadBuffer for some standard generic types, such as alloc::Box<[u8; N]>, heapless::Box<[u8; N]> et. al.
ReadTarget
ReadBuffer
alloc::Box<[u8; N]>
unsafe impl<B, T> ReadBuffer for B where B: Deref<Target = T> + StableDeref + 'static, T: ReadTarget + ?Sized, {...}
But it not works automatically with newtype structs with Deref:
newtype
Deref
pub struct MyArray([u8; 100]); impl Deref for MyArray { type Target = [u8]; fn deref(&self) -> &[u8] { &self.0 } } #[entry] fn main() -> ! { let a = alloc::Box::new(MyArray([0; 100])); unsafe { a.read_buffer(); } loop {} }
error[E0599]: the method read_bufferexists for structBox, but its trait bounds were not satisfied.
error[E0599]: the method
exists for struct
, but its trait bounds were not satisfied
I can implement ReadTarget manually, and then code will be compiled:
unsafe impl ReadTarget for MyArray { type Word = u8; fn as_read_buffer(&self) -> (*const Self::Word, usize) { self.deref().as_read_buffer() } }
Why my code not works by using Deref only?
P.S. Full example
The text was updated successfully, but these errors were encountered:
embedded_dma
This repo is dead?
Sorry, something went wrong.
No branches or pull requests
ReadTarget
allows implementReadBuffer
for some standard generic types, such asalloc::Box<[u8; N]>
, heapless::Box<[u8; N]> et. al.But it not works automatically with
newtype
structs withDeref
:error[E0599]: the method
read_bufferexists for struct
Box, but its trait bounds were not satisfied
.I can implement
ReadTarget
manually, and then code will be compiled:Why my code not works by using
Deref
only?P.S. Full example
The text was updated successfully, but these errors were encountered: