lucia_lang/objects/
error.rs1use std::{borrow::Borrow, ops::Deref};
2
3use gc_arena::{Collect, Gc, Mutation};
4
5use crate::errors::Error;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Collect)]
8#[collect(no_drop)]
9pub struct GcError<'gc>(pub Gc<'gc, Error<'gc>>);
10
11impl<'gc> Deref for GcError<'gc> {
12 type Target = Error<'gc>;
13
14 fn deref(&self) -> &Self::Target {
15 &self.0
16 }
17}
18
19impl<'gc> AsRef<Error<'gc>> for GcError<'gc> {
20 fn as_ref(&self) -> &Error<'gc> {
21 &self.0
22 }
23}
24
25impl<'gc> Borrow<Error<'gc>> for GcError<'gc> {
26 fn borrow(&self) -> &Error<'gc> {
27 &self.0
28 }
29}
30
31impl<'gc> GcError<'gc> {
32 pub fn new(mc: &Mutation<'gc>, e: Error<'gc>) -> GcError<'gc> {
33 GcError(Gc::new(mc, e))
34 }
35}