rustfmt with nightly options

also some other minor formatting changes
This commit is contained in:
Moritz Gmeiner 2024-09-03 16:48:00 +02:00
commit f8b59e6034
17 changed files with 91 additions and 291 deletions

View file

@ -16,7 +16,8 @@ pub struct LoxClass {
methods: FxHashMap<String, Value>,
}
/// Representation of a class in Lox. Always behind an Rc to ensure uniqueness. Should never be handled raw.
/// Representation of a class in Lox. Always behind an Rc to ensure uniqueness. Should never be
/// handled raw.
impl LoxClass {
pub fn new(
name: impl Into<SmolStr>,
@ -81,19 +82,10 @@ impl LoxClass {
return method.arity();
}
/* if let Some(superclass) = self.superclass {
return superclass.arity();
} */
0
}
pub fn get_method(&self, name: &str, this: LoxReference) -> Option<Value> {
/* self.methods
.get(name)
.cloned()
.or_else(|| self.superclass.as_ref().and_then(|cls| cls.get_method(name))) */
if let Some(method) = self.methods.get(name) {
match method {
Value::Function(method) => {
@ -111,19 +103,6 @@ impl LoxClass {
None
}
/* pub fn init(&self, args: Vec<Value>, env: &mut Environment) -> EvalResult<()> {
if let Some(ref superclass) = self.superclass {
let args = args.clone();
superclass.init(args, env)?;
}
if let Some(Value::Function(method)) = self.get_method("init") {
method.call(args, env)?;
}
Ok(())
} */
}
impl Display for LoxClass {
@ -138,7 +117,8 @@ impl Display for LoxClass {
}
// slightly hacky: two classes are equal if they are stored at the same location
// since a LoxClass is always (supposed to be) behind an Rc anyways, we might as well compare their pointers
// since a LoxClass is always (supposed to be) behind an Rc anyways, we might as well compare their
// pointers
impl PartialEq for LoxClass {
fn eq(&self, other: &Self) -> bool {
let self_ptr = self as *const LoxClass;