chore: cargo fmt

This commit is contained in:
2025-05-17 20:08:16 +08:00
parent ec61eaa140
commit c3d365d486
5 changed files with 25 additions and 28 deletions

View File

@@ -97,7 +97,9 @@ impl Compile for ir::Thunk {
impl Compile for ir::Attrs {
fn compile(self, comp: &mut Compiler) {
comp.push(OpCode::AttrSet { cap: self.stcs.len() + self.dyns.len() });
comp.push(OpCode::AttrSet {
cap: self.stcs.len() + self.dyns.len(),
});
for stc in self.stcs {
stc.1.compile(comp);
if !self.rec {

View File

@@ -1,5 +1,3 @@
use std::hash::Hash;
use hashbrown::{HashMap, HashSet};
use derive_more::Constructor;
@@ -25,7 +23,9 @@ impl<'vm> AttrSet<'vm> {
}
pub fn with_capacity(cap: usize) -> Self {
AttrSet { data: HashMap::with_capacity(cap) }
AttrSet {
data: HashMap::with_capacity(cap),
}
}
pub fn push_attr_force(&mut self, sym: usize, val: Value<'vm>) {

View File

@@ -1,6 +1,6 @@
use hashbrown::HashSet;
use std::cell::OnceCell;
use std::cell::RefCell;
use hashbrown::HashSet;
use std::hash::Hash;
use std::rc::Rc;

View File

@@ -1,5 +1,5 @@
use std::rc::Rc;
use hashbrown::HashMap;
use std::rc::Rc;
use crate::ty::internal::{AttrSet, Value};
@@ -16,7 +16,7 @@ impl<'vm> Env<'vm> {
pub fn lookup(&self, symbol: usize) -> Option<Value<'vm>> {
if let Some(val) = self.map.get(&symbol).cloned() {
return Some(val)
return Some(val);
}
self.last.as_ref().map(|env| env.lookup(symbol)).flatten()
}
@@ -26,10 +26,6 @@ impl<'vm> Env<'vm> {
}
pub fn enter(self, new: impl Iterator<Item = (usize, Value<'vm>)>) -> Self {
/* let mut map = self.map.clone();
for (k, v) in new {
map.insert_mut(k, v);
} */
let map = Rc::new(new.collect());
let last = Some(
Env {
@@ -42,22 +38,21 @@ impl<'vm> Env<'vm> {
}
pub fn enter_with(self, new: Rc<AttrSet<'vm>>) -> Self {
/* let mut map = self.map.clone();
for (k, v) in new.as_inner().iter() {
let v = if let Value::Builtins = v {
Value::AttrSet(new.clone())
} else {
v.clone()
};
map.insert_mut(k.clone(), v);
} */
let map = Rc::new(new.as_inner().iter().map(|(&k, v)| {
(k, if let Value::Builtins = v {
Value::AttrSet(new.clone())
} else {
v.clone()
})
}).collect());
let map = Rc::new(
new.as_inner()
.iter()
.map(|(&k, v)| {
(
k,
if let Value::Builtins = v {
Value::AttrSet(new.clone())
} else {
v.clone()
},
)
})
.collect(),
);
let last = Some(
Env {
last: self.last.clone(),

View File

@@ -1,5 +1,5 @@
use std::cell::RefCell;
use hashbrown::{HashMap, HashSet};
use std::cell::RefCell;
use std::pin::Pin;
use crate::builtins::env;