From 0a2dd7a14884bf962669889401ed321f18945de7 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Sat, 05 Jun 2021 18:47:21 +0000 Subject: [PATCH] feat(jrsonnet-types): implement gc It is currently not possible to implement recursive type, so all tracing is noop here --- --- a/crates/jrsonnet-types/Cargo.toml +++ b/crates/jrsonnet-types/Cargo.toml @@ -8,3 +8,4 @@ [dependencies] peg = "0.7.0" +gc = { version = "0.4.1", features = ["derive"] } --- a/crates/jrsonnet-types/src/lib.rs +++ b/crates/jrsonnet-types/src/lib.rs @@ -1,5 +1,6 @@ #![allow(clippy::redundant_closure_call)] +use gc::{unsafe_empty_trace, Finalize, Trace}; use std::fmt::Display; #[macro_export] @@ -87,6 +88,10 @@ Obj, Func, } +impl Finalize for ValType {} +unsafe impl Trace for ValType { + unsafe_empty_trace!(); +} impl ValType { pub const fn name(&self) -> &'static str { @@ -123,6 +128,11 @@ Sum(Vec), SumRef(&'static [ComplexValType]), } +impl Finalize for ComplexValType {} +unsafe impl Trace for ComplexValType { + unsafe_empty_trace!(); +} + impl From for ComplexValType { fn from(s: ValType) -> Self { Self::Simple(s) -- gitstuff