According to the documentation, the end-user should be able to implement their own Static{Read,Write}Buffer for a non-static type. However, due to orphan rules, I do not think this is possible.
Take the case of StaticReadBuffer
pub unsafe trait StaticReadBuffer: ReadBuffer { }
If we want to implement this for our type we must also implement ReadBuffer, but there is already a blanket implementation
unsafe impl<B: WriteBuffer + 'static> StaticWriteBuffer for B {
type Word = <Self as WriteBuffer>::Word;
unsafe fn static_write_buffer(&mut self) -> (*mut <Self as StaticWriteBuffer>::Word, usize) {
self.write_buffer()
}
}
and afaik there is no way to denote a type as non-static. Ideally the end-user would be able to
unsafe impl StaticWriteBuffer for NotReallyStatic<'a> where 'a!: 'static {
// ...
}
where ! is not.
Proposal
Remove the blanket implementations and perhaps only implement StaticWriteBuffer for slices and semi-concrete types.
According to the documentation, the end-user should be able to implement their own
Static{Read,Write}Buffer
for a non-static type. However, due to orphan rules, I do not think this is possible.Take the case of
StaticReadBuffer
If we want to implement this for our type we must also implement
ReadBuffer
, but there is already a blanket implementationand afaik there is no way to denote a type as non-static. Ideally the end-user would be able to
where
!
is not.Proposal
Remove the blanket implementations and perhaps only implement
StaticWriteBuffer
for slices and semi-concrete types.