mirror of
https://github.com/teo3300/rust-mal.git
synced 2026-01-12 09:15:32 +01:00
Clippy fix, removed some Debug traits
Signed-off-by: teo3300 <matteo.rogora@live.it>
This commit is contained in:
@ -36,7 +36,7 @@ use crate::types::MalType::{Bool, Fun, Int, List, Nil, Str};
|
||||
use crate::types::{mal_assert, mal_assert_eq, mal_comp, MalArgs};
|
||||
|
||||
pub fn ns_init() -> Env {
|
||||
let env_t = env_init!(None,
|
||||
env_init!(None,
|
||||
"test" => Fun(|_| Ok(Str("This is a test function".to_string())), "Just a test function"),
|
||||
"exit" => Fun(mal_exit, "Quits the program with specified status"),
|
||||
"+" => Fun(|a| arithmetic_op(0, |a, b| a + b, a), "Returns the sum of the arguments"),
|
||||
@ -63,8 +63,7 @@ pub fn ns_init() -> Env {
|
||||
"=" => Fun(mal_comp, "Return true if the first two parameters are the same type and content, in case of lists propagate to all elements"),
|
||||
"assert" => Fun(mal_assert, "Return an error if assertion fails"),
|
||||
"assert-eq" => Fun(mal_assert_eq, "Return an error if arguments are not the same"),
|
||||
"read-string" => Fun(|a| read_str(&Reader::new().push(car(a)?.if_string()?)), "Tokenize and read the first argument"),
|
||||
"read-string" => Fun(|a| read_str(Reader::new().push(car(a)?.if_string()?)), "Tokenize and read the first argument"),
|
||||
"slurp" => Fun(|a| Ok(Str(read_file(car(a)?.if_string()?)?)), "Read a file and return the content as a string")
|
||||
);
|
||||
env_t
|
||||
)
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ use crate::types::{MalMap, MalRet, MalType};
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub struct EnvType {
|
||||
data: RefCell<MalMap>,
|
||||
pub outer: Option<Env>,
|
||||
|
||||
@ -11,10 +11,10 @@ use std::path::Path;
|
||||
use std::process::exit;
|
||||
|
||||
pub fn load_core(env: &Env) {
|
||||
eval_str("(def! not (fn* (x) (if x nil true)))", &env).unwrap();
|
||||
eval_str("(def! not (fn* (x) (if x nil true)))", env).unwrap();
|
||||
eval_str(
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))",
|
||||
&env,
|
||||
env,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
@ -32,9 +32,8 @@ pub fn load_conf(work_env: &Env) {
|
||||
let config = home + "/" + CONFIG;
|
||||
|
||||
if Path::new(&config).exists() {
|
||||
match load_file(&config, work_env) {
|
||||
Err(e) => eprintln!("{}", e.message()),
|
||||
_ => (),
|
||||
if let Err(e) = load_file(&config, work_env) {
|
||||
eprintln!("{}", e.message())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ use crate::env::{car_cdr, Env};
|
||||
use std::{collections::HashMap, rc::Rc};
|
||||
|
||||
// All Mal types should inherit from this
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub enum MalType {
|
||||
List(MalArgs),
|
||||
Vector(MalArgs),
|
||||
|
||||
Reference in New Issue
Block a user