Skip to content

Commit a5e027e

Browse files
committed
Fix lifetimes
1 parent bc70f92 commit a5e027e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

borsh/src/de/mod.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -1654,8 +1654,23 @@ pub fn from_slice<T: BorshDeserialize>(v: &[u8]) -> Result<T> {
16541654
/// ```
16551655
#[async_generic(
16561656
#[cfg(feature = "unstable__async")]
1657-
async_signature[impl_fut]<'a, R: AsyncRead, T: BorshDeserializeAsync + 'a>(reader: &'a mut R) -> impl Future<Output=Result<T>> + Send + 'a
1657+
async_signature[impl_fut]<R: AsyncRead, T: BorshDeserializeAsync>(
1658+
reader: &mut R,
1659+
) -> impl Future<Output=Result<T>> + Send + Captures<&mut R>
16581660
)]
16591661
pub fn from_reader<R: Read, T: BorshDeserialize>(reader: &mut R) -> Result<T> {
16601662
T::try_from_reader(reader)
16611663
}
1664+
1665+
use captures::Captures;
1666+
mod captures {
1667+
/// This is a [trick](https://github.com/rust-lang/rfcs/blob/master/text/3498-lifetime-capture-rules-2024.md#the-captures-trick),
1668+
/// used to not over-restrict the lifetime and trait bounds of a RPIT.
1669+
///
1670+
/// Once the MSRV is >=1.82, this should be removed and replaced with `use<>`
1671+
/// notation for precise capturing.
1672+
#[doc(hidden)]
1673+
pub trait Captures<T: ?Sized> {}
1674+
1675+
impl<T: ?Sized, U: ?Sized> Captures<T> for U {}
1676+
}

0 commit comments

Comments
 (0)