MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / try_map_root

Method try_map_root

aiscript-arena/src/arena.rs:185–202  ·  view source on GitHub ↗
(
        self,
        f: impl for<'gc> FnOnce(&'gc Mutation<'gc>, Root<'gc, R>) -> Result<Root<'gc, R2>, E>,
    )

Source from the content-addressed store, hash-verified

183
184 #[inline]
185 pub fn try_map_root<R2, E>(
186 self,
187 f: impl for<'gc> FnOnce(&'gc Mutation<'gc>, Root<'gc, R>) -> Result<Root<'gc, R2>, E>,
188 ) -> Result<Arena<R2>, E>
189 where
190 R2: for<'a> Rootable<'a>,
191 for<'a> Root<'a, R2>: Sized,
192 {
193 self.context.root_barrier();
194 let new_root: Root<'static, R2> = unsafe {
195 let mc: &'static Mutation<'_> = &*(self.context.mutation_context() as *const _);
196 f(mc, self.root)?
197 };
198 Ok(Arena {
199 context: self.context,
200 root: new_root,
201 })
202 }
203}
204
205impl<R> Arena<R>

Callers

nothing calls this directly

Calls 2

root_barrierMethod · 0.80
mutation_contextMethod · 0.80

Tested by

no test coverage detected