Skip to content

Commit

Permalink
Merge pull request #69 from earthstar-project/wb_cleanup
Browse files Browse the repository at this point in the history
wb_async_utils cleanup
  • Loading branch information
AljoschaMeyer authored Jan 5, 2025
2 parents 25ba591 + 8815c2d commit 9337925
Show file tree
Hide file tree
Showing 6 changed files with 790 additions and 154 deletions.
14 changes: 14 additions & 0 deletions wb_async_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,17 @@ pub mod spsc;

#[cfg(feature = "ufotofu_utils")]
pub mod shared_producer;

// This is safe if and only if the object pointed at by `reference` lives for at least `'longer`.
// See https://doc.rust-lang.org/nightly/std/intrinsics/fn.transmute.html for more detail.
pub(crate) unsafe fn extend_lifetime<'shorter, 'longer, T: ?Sized>(reference: &'shorter T) -> &'longer T {
core::mem::transmute::<&'shorter T, &'longer T>(reference)
}

// This is safe if and only if the object pointed at by `reference` lives for at least `'longer`.
// See https://doc.rust-lang.org/nightly/std/intrinsics/fn.transmute.html for more detail.
pub(crate) unsafe fn extend_lifetime_mut<'shorter, 'longer, T: ?Sized>(
reference: &'shorter mut T,
) -> &'longer mut T {
core::mem::transmute::<&'shorter mut T, &'longer mut T>(reference)
}
Loading

0 comments on commit 9337925

Please sign in to comment.