pub fn try_map<U: ?Sized, F>(this: Self, f: F) -> Option<Mut<U>>
    where
        F: FnOnce(&mut T) -> Option<&mut U>,
    {
        let Self {
            mut data,
            guard,
            inner,
            ..
        } = this;

        // Safety: this follows the same safety guarantees as when the managed
        // ref was acquired. And since we have a managed reference to `T`, we're
        // permitted to do any sort of projection to `U`.
        f(unsafe { data.as_mut() }).map(|data| Mut {
            data: data.into(),
            guard,
            inner,
        })
    }
/// Try to map the mutable reference to a projection.
///
/// # Examples
///
/// ```rust
/// use runestick::{Mut, Shared};
///
/// # fn main() -> runestick::Result<()> {
/// let vec = Shared::<Vec<u32>>::new(vec![1, 2, 3, 4]);
/// let vec = vec.into_mut()?;
/// let mut value: Option<Mut<[u32]>> = Mut::try_map(vec, |vec| vec.get_mut(0..2));
///
/// assert_eq!(value.as_deref_mut(), Some(&mut [1u32, 2u32][..]));
/// # Ok(()) }
/// ```
Try to map the mutable reference to a projection.
Try to map the mutable reference to a projection .
pub fn try_map<U: ?Sized, F>(this: Self, f: F) -> Option<Mut<U>>
    where
        F: FnOnce(&mut T) -> Option<&mut U>,
    {
        let Self {
            mut data,
            guard,
            inner,
            ..
        } = this;
        // Safety: this follows the same safety guarantees as when the managed
        // ref was acquired. And since we have a managed reference to `T`, we're
        // permitted to do any sort of projection to `U`.
        f(unsafe { data.as_mut() }).map(|data| Mut {
            data: data.into(),
            guard,
            inner,
        })
    }
pub fn try_map < U : ? Sized , F > ( this : Self , f : F ) -> Option < Mut < U > > where F : FnOnce ( & mut T ) -> Option < & mut U > , { let Self { mut data , guard , inner , .. } = this ; // Safety: this follows the same safety guarantees as when the managed // ref was acquired. And since we have a managed reference to `T`, we're // permitted to do any sort of projection to `U`. f ( unsafe { data . as_mut ( ) } ) . map ( | data | Mut { data : data . into ( ) , guard , inner , } ) }
Try to map the mutable reference to a projection.
Try to map the mutable reference to a projection .
this
Self
f
F
this
Self
f
F
examples
```rust
use runestick::{Mut, Shared}.
` ` ` rust use runestick :: { Mut Shared } .
fn main() -> runestick::result<()> {
None
ok(()) }
None