Skip to content

Commit

Permalink
Merge pull request #284 from caido/ef-trace-improvements
Browse files Browse the repository at this point in the history
Trace improvements
  • Loading branch information
DelSkayn committed Mar 28, 2024
2 parents c0dd290 + 147313b commit 9e8cc41
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions core/src/class/trace.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use std::marker::PhantomData;

#[cfg(feature = "either")]
use either::{Either, Left, Right};

use crate::{markers::Invariant, qjs, Class, Ctx, Value};

use super::JsClass;
Expand Down Expand Up @@ -77,6 +80,32 @@ where
}
}

impl<'js, T> Trace<'js> for Option<T>
where
T: Trace<'js>,
{
fn trace<'a>(&self, tracer: Tracer<'a, 'js>) {
if let Some(inner) = &self {
inner.trace(tracer);
}
}
}

#[cfg(feature = "either")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "either")))]
impl<'js, L, R> Trace<'js> for Either<L, R>
where
L: Trace<'js>,
R: Trace<'js>,
{
fn trace<'a>(&self, tracer: Tracer<'a, 'js>) {
match self {
Left(l) => l.trace(tracer),
Right(r) => r.trace(tracer),
}
}
}

macro_rules! trace_impls {

(primitive: $( $(#[$meta:meta])* $($type:ident)::+$(<$lt:lifetime>)?,)*) => {
Expand Down
1 change: 1 addition & 0 deletions macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ mod trace;
/// | `set` | Flag | Creates a setter for this field, allowing write access to the field from JavaSccript. |
/// | `enumerable` | Flag | Makes the field, if it has a getter or setter, enumerable in JavaScript. |
/// | `configurable` | Flag | Makes the field, if it has a getter or setter, configurable in JavaScript. |
/// | `skip_trace` | Flag | Skips the field deriving the `Trace` trait. |
/// | `rename` | String | Changes the name of the field getter and/or setter to the specified name in JavaScript. |
///
///
Expand Down

0 comments on commit 9e8cc41

Please sign in to comment.