Similar to `new`, but allows for constructor that can fail.
(f: F)
| 150 | |
| 151 | /// Similar to `new`, but allows for constructor that can fail. |
| 152 | pub fn try_new<F, E>(f: F) -> Result<Arena<R>, E> |
| 153 | where |
| 154 | F: for<'gc> FnOnce(&'gc Mutation<'gc>) -> Result<Root<'gc, R>, E>, |
| 155 | { |
| 156 | unsafe { |
| 157 | let context = Box::new(Context::new()); |
| 158 | let mc: &'static Mutation<'_> = &*(context.mutation_context() as *const _); |
| 159 | let root: Root<'static, R> = f(mc)?; |
| 160 | Ok(Arena { context, root }) |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | #[inline] |
| 165 | pub fn map_root<R2>( |
nothing calls this directly
no test coverage detected