Skip to main content

luaur_common/methods/
f_value_f_value.rs

1//! `FValue<T>::FValue(const char* name, T def, bool dynamic)`. Reference:
2//! `luau/Common/include/Luau/Common.h`.
3//!
4//! Field init only — a `const fn` so flags can be `static`. The C++ ctor's
5//! `list = this` side effect is [`FValue::register`] (see the deviation note in
6//! [`crate::records::f_value`]).
7
8use core::cell::UnsafeCell;
9use core::ffi::c_char;
10
11use crate::records::f_value::FValue;
12
13impl<T: Copy> FValue<T> {
14    pub const fn new(name: *const c_char, def: T, dynamic: bool) -> Self {
15        FValue {
16            value: UnsafeCell::new(def),
17            dynamic,
18            name,
19            next: UnsafeCell::new(core::ptr::null()),
20            version: UnsafeCell::new(0),
21        }
22    }
23}