Skip to content

Commit

Permalink
Document unchecked_sidecast_triomphe_arc
Browse files Browse the repository at this point in the history
  • Loading branch information
bgw committed Jul 29, 2024
1 parent 05abdbc commit 6bb3574
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/turbo-tasks/src/triomphe_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use unsize::Coercion;
/// Attempt to downcast a [`triomphe::Arc<dyn Any + Send +
/// Sync>`][`triomphe::Arc`] to a concrete type.
///
/// Checks that the downcast is safe using [`Any::is`].
///
/// Ported from [`std::sync::Arc::downcast`] to [`triomphe::Arc`].
pub fn downcast_triomphe_arc<T: Any + Send + Sync>(
this: triomphe::Arc<dyn Any + Send + Sync>,
Expand All @@ -16,6 +18,16 @@ pub fn downcast_triomphe_arc<T: Any + Send + Sync>(
}
}

/// Transmutes the contents of `Arc<T>` to `Arc<U>`. Updates the `Arc`'s fat
/// pointer metadata.
///
/// Unlike [`downcast_triomphe_arc`] this make no checks the transmute is safe.
///
/// # Safety
///
/// It must be [safe to transmute][transmutes] from `T` to `U`.
///
/// [transmutes]: https://doc.rust-lang.org/nomicon/transmutes.html
pub unsafe fn unchecked_sidecast_triomphe_arc<T, U>(this: triomphe::Arc<T>) -> triomphe::Arc<U>
where
T: ?Sized,
Expand Down

0 comments on commit 6bb3574

Please sign in to comment.