feat: ref
This commit is contained in:
@@ -8,29 +8,29 @@ use crate::vm::VM;
|
||||
use super::{ToPublic, Value};
|
||||
|
||||
#[derive(Debug, Constructor, Clone, PartialEq)]
|
||||
pub struct List {
|
||||
data: VectorSync<Value>,
|
||||
pub struct List<'vm> {
|
||||
data: VectorSync<Value<'vm>>,
|
||||
}
|
||||
|
||||
impl List {
|
||||
pub fn empty() -> List {
|
||||
impl<'vm> List<'vm> {
|
||||
pub fn empty() -> Self {
|
||||
List {
|
||||
data: VectorSync::new_sync(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push(&mut self, elem: Value) {
|
||||
pub fn push(&mut self, elem: Value<'vm>) {
|
||||
self.data.push_back_mut(elem);
|
||||
}
|
||||
|
||||
pub fn concat(mut self, other: List) -> List {
|
||||
pub fn concat(mut self, other: List<'vm>) -> List<'vm> {
|
||||
for elem in other.data.iter() {
|
||||
self.data.push_back_mut(elem.clone());
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
pub fn force_deep(&mut self, vm: &VM) -> Result<()> {
|
||||
pub fn force_deep(&mut self, vm: &VM<'vm>) -> Result<()> {
|
||||
let mut vec: Vec<_> = self.data.iter().cloned().collect();
|
||||
vec.iter_mut()
|
||||
.map(|v| v.force_deep(vm).map(|_| ()))
|
||||
@@ -41,7 +41,7 @@ impl List {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPublic for List {
|
||||
impl ToPublic for List<'_> {
|
||||
fn to_public(self, vm: &VM) -> p::Value {
|
||||
p::Value::List(p::List::new(
|
||||
self.data
|
||||
|
||||
Reference in New Issue
Block a user