rhai 1.27.0

Embedded scripting for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::grain::bytecode::constant_caps;
use crate::Dynamic;
#[cfg(feature = "no_std")]
use std::prelude::v1::*;

/// Whether a constant can live in the artifact's constant pool.
///
/// Two constraints happen to coincide here, so one check enforces both.
///
/// The artifact must be loadable in another process, which rules out anything
/// carrying a host `TypeId`, a live `Rc`, or a clock reading: `Variant`,
/// `Shared`, `TimeStamp`.
pub(crate) fn is_poolable(value: &Dynamic) -> bool {
    // Check if the value is a valid constant.
    // Anything else — TimeStamp, a custom type, a shared cell, etc.,
    // cannot be pooled.
    constant_caps(value).is_some()
}