Skip to content

Commit

Permalink
Freeze for ValueTypedComplex
Browse files Browse the repository at this point in the history
Summary: Obvious implementation.

Reviewed By: samkevich

Differential Revision: D53930589

fbshipit-source-id: 7da426458399e2f140c30171302b85f9401c0000
  • Loading branch information
stepancheg authored and facebook-github-bot committed Feb 20, 2024
1 parent fa9cf3c commit 0a8b9b8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions starlark/src/values/layout/complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::fmt;
use std::marker::PhantomData;

use allocative::Allocative;
use anyhow::Context;
use dupe::Clone_;
use dupe::Copy_;
use dupe::Dupe_;
Expand All @@ -28,6 +29,9 @@ use crate::typing::Ty;
use crate::values::type_repr::StarlarkTypeRepr;
use crate::values::AllocValue;
use crate::values::ComplexValue;
use crate::values::Freeze;
use crate::values::Freezer;
use crate::values::FrozenValueTyped;
use crate::values::StarlarkValue;
use crate::values::Trace;
use crate::values::Tracer;
Expand Down Expand Up @@ -146,6 +150,18 @@ where
}
}

impl<'v, T> Freeze for ValueTypedComplex<'v, T>
where
T: ComplexValue<'v>,
T::Frozen: StarlarkValue<'static>,
{
type Frozen = FrozenValueTyped<'static, T::Frozen>;

fn freeze(self, freezer: &Freezer) -> anyhow::Result<Self::Frozen> {
FrozenValueTyped::new(self.0.freeze(freezer)?).context("Incorrect type")
}
}

#[cfg(test)]
mod tests {
use allocative::Allocative;
Expand Down

0 comments on commit 0a8b9b8

Please sign in to comment.