feat: usable?

This commit is contained in:
2025-05-05 11:31:46 +08:00
parent eea4a4ce9f
commit b9dcc83c39
24 changed files with 688 additions and 244 deletions

View File

@@ -1,10 +1,11 @@
use anyhow::Result;
use derive_more::Constructor;
use rpds::VectorSync;
use crate::ty::public as p;
use crate::vm::VM;
use super::{ToPublic, Value};
use crate::vm::VM;
#[derive(Debug, Constructor, Clone, PartialEq)]
pub struct List {
@@ -14,7 +15,7 @@ pub struct List {
impl List {
pub fn empty() -> List {
List {
data: VectorSync::new_sync()
data: VectorSync::new_sync(),
}
}
@@ -28,6 +29,16 @@ impl List {
}
self
}
pub fn force_deep(&mut self, vm: &VM) -> Result<()> {
let mut vec: Vec<_> = self.data.iter().cloned().collect();
vec.iter_mut()
.map(|v| v.force_deep(vm).map(|_| ()))
.find(|v| matches!(v, Err(_)))
.map_or(Ok(()), |err| err)?;
self.data = vec.into_iter().collect();
Ok(())
}
}
impl ToPublic for List {