some rustfmt updates

This commit is contained in:
Ava Hahn 2023-03-07 21:31:54 -08:00
parent 0c5d14ed8e
commit 5d89c6b684
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
3 changed files with 15 additions and 13 deletions

View file

@ -210,7 +210,7 @@ Will need a concatenate function for tables
**** DONE mul
**** DONE exp
**** DONE mod
***** TODO Test for Let Destructuring
***** DONE Test for Let Destructuring
**** TODO inc
**** TODO dec
**** TODO gt?

View file

@ -25,7 +25,8 @@ fn isnumeric(arg: &Ctr) -> bool {
}
}
pub const ADD_DOCSTRING: &str = "traverses over N args, which must all evaluate to an Integer or Float.
pub const ADD_DOCSTRING: &str =
"traverses over N args, which must all evaluate to an Integer or Float.
Adds each arg up to a final result. WARNING: does not acocunt for under/overflows.
Consult source code for a better understanding of how extreme values will be handled.";
@ -55,7 +56,7 @@ Consult source code for a better understanding of how extreme values will be han
pub fn sub_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
if !isnumeric(&*ast.car) {
return Err(format!("{} is not a number", &*ast.car))
return Err(format!("{} is not a number", &*ast.car));
}
let mut res = *ast.car.clone();
let mut culprit: Ctr = Ctr::None;
@ -80,7 +81,6 @@ pub fn sub_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
}
}
pub const DIV_DOCSTRING: &str = "takes two args, which must both evaluate to an Integer or Float.
divides arg1 by arg2. WARNING: does not acocunt for under/overflows or float precision.
Consult source code for a better understanding of how extreme values will be handled.";
@ -102,7 +102,8 @@ pub fn div_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
}
}
pub const MUL_DOCSTRING: &str = "traverses over N args, which must all evaluate to an Integer or Float.
pub const MUL_DOCSTRING: &str =
"traverses over N args, which must all evaluate to an Integer or Float.
Multiplies each arg up to a final result. WARNING: does not acocunt for under/overflows.
Consult source code for a better understanding of how extreme values will be handled.";
@ -239,27 +240,27 @@ pub fn mod_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
Ctr::Float(rf) => {
ret.append(Box::new(Ctr::Integer((lf / rf) as i128)));
ret.append(Box::new(Ctr::Integer((lf % rf) as i128)));
},
}
Ctr::Integer(ri) => {
ret.append(Box::new(Ctr::Integer((lf / ri as f64) as i128)));
ret.append(Box::new(Ctr::Integer((lf % ri as f64) as i128)));
},
}
_ => return Err("mod not implemented for these arguments".to_string()),
},
Ctr::Integer(li) => match second {
Ctr::Float(rf) => {
ret.append(Box::new(Ctr::Integer((li as f64 / rf) as i128)));
ret.append(Box::new(Ctr::Integer((li as f64 % rf) as i128))); },
ret.append(Box::new(Ctr::Integer((li as f64 % rf) as i128)));
}
Ctr::Integer(ri) => {
ret.append(Box::new(Ctr::Integer(li / ri)));
ret.append(Box::new(Ctr::Integer(li % ri)));
},
}
_ => return Err("mod not implemented for these arguments".to_string()),
},
_ => return Err("mod not implemented for these arguments".to_string()),
}
Ok(Ctr::Seg(ret))
}

View file

@ -258,7 +258,8 @@ mod math_lib_tests {
fn test_fi_mod() {
let document = "(def test '' (mod 7.2 2))";
let check1 = "(car test)";
let result1 = "3"; let mut syms = SymTable::new();
let result1 = "3";
let mut syms = SymTable::new();
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
let _ = *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();