Coverage Report

Created: 2025-12-14 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/yoke-0.8.1/src/utils.rs
Line
Count
Source
1
// This file is part of ICU4X. For terms of use, please see the file
2
// called LICENSE at the top level of the ICU4X source tree
3
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5
use crate::Yokeable;
6
use core::mem;
7
8
/// This method casts `yokeable` between `&'a mut Y<'static>` and `&'a mut Y<'a>`,
9
/// and passes it to `f`.
10
///
11
/// See [`Yokeable::transform_mut`] for why this is safe, noting that no `'static` return type
12
/// can leak data from the cart or Yokeable.
13
#[inline]
14
0
pub(crate) fn transform_mut_yokeable<'a, Y, F, R>(yokeable: &'a mut Y, f: F) -> R
15
0
where
16
0
    Y: Yokeable<'a>,
17
0
    // be VERY CAREFUL changing this signature, it is very nuanced
18
0
    F: 'static + for<'b> FnOnce(&'b mut Y::Output) -> R,
19
0
    R: 'static,
20
{
21
    // Cast away the lifetime of `Y`
22
    // Safety: this is equivalent to f(transmute(yokeable)), and the documentation of
23
    // [`Yokeable::transform_mut`] and this function explain why doing so is sound.
24
0
    unsafe { f(mem::transmute::<&'a mut Y, &'a mut Y::Output>(yokeable)) }
25
0
}