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
286: blocking/spi: Don't return the same buffer back. r=therealprof a=Dirbaio
This is a rather minor improvement to the blocking SPI Transfer trait, but that IMO is still worth it.
Old: `fn transfer<'w>(&mut self, words: &'w mut [W]) -> Result<&'w [W], Self::Error>`
New: `fn transfer(&mut self, words: &mut [W]) -> Result<(), Self::Error>`
It is redundant (and confusing IMO) to return back the same buffer the user has passed in. It allows for 2 ways of writing the same thing: use the returned buffer, or ignore it and use the buffer that was passed in. It's not obvious which is better, and from the docs it's not obvious that both are really the same either.
Also, with the old signature, it is possible for implementors to return a subslice of the buffer instead of the whole buffer. This would be arguably wrong and would break user code that assumes the entire buffer is returned. Not re-returning the buffer makes this mistake impossible.
Co-authored-by: Dario Nieuwenhuis <[email protected]>
0 commit comments