Fix #2612: adjust readable trait to allow try_peek (#2714)

* Fix #2612: adjust readable trait to allow try_peek

Our implementation for Readable was inconsistent.
We had a try_unchecked variant for read but not for peek.
This resolves that by making a breaking change to the
Readable interface.

* fix doctests too
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-07-26 18:20:16 -05:00
1 parent 443b9a4af6
commit e42b71b1ba
13 files changed
+102 -58

No files matched your search

+16 -8
View File
@@ -25,8 +25,10 @@
/// self.value.try_read_unchecked()
/// }
///
/// fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
/// self.value.read_unchecked()
/// fn try_peek_unchecked(
/// &self,
/// ) -> Result<ReadableRef<'static, Self>, generational_box::BorrowError> {
/// self.value.try_read_unchecked()
/// }
/// }
///
@@ -85,8 +87,10 @@ macro_rules! default_impl {
/// self.value.try_read_unchecked()
/// }
///
/// fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
/// self.value.read_unchecked()
/// fn try_peek_unchecked(
/// &self,
/// ) -> Result<ReadableRef<'static, Self>, generational_box::BorrowError> {
/// self.value.try_read_unchecked()
/// }
/// }
///
@@ -156,8 +160,10 @@ macro_rules! read_impls {
/// self.value.try_read_unchecked()
/// }
///
/// fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
/// self.value.read_unchecked()
/// fn try_peek_unchecked(
/// &self,
/// ) -> Result<ReadableRef<'static, Self>, generational_box::BorrowError> {
/// self.value.try_read_unchecked()
/// }
/// }
///
@@ -230,8 +236,10 @@ macro_rules! fmt_impls {
/// self.value.try_read_unchecked()
/// }
///
/// fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
/// self.value.read_unchecked()
/// fn try_peek_unchecked(
/// &self,
/// ) -> Result<ReadableRef<'static, Self>, generational_box::BorrowError> {
/// self.value.try_read_unchecked()
/// }
/// }
///