From 78f83825024d528fdc3373667cc4164acab8aebd Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Thu, 30 Dec 2021 13:50:52 +0100 Subject: [PATCH] small api changes --- clippy.toml | 10 ++++------ src/lex.rs | 4 ++-- src/lib.rs | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/clippy.toml b/clippy.toml index 7c0ab05..e2a9559 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,8 +1,6 @@ disallowed-types = [ - # we want to use our custom HashMap/HashSet from `values.rs`, so that consumers can choose between which HashMap they want - "std::collections::HashMap", - "std::collections::HashSet", - # we want to use bumpalo::collections::Vec, this can be removed later I guess - "std::collections::Vec", - "std::boxed::Box", + { path = "std::collections::HashMap", reason = "may be fxhash or siphash, depending on the feature, stay flexible" }, + { path = "std::collections::HashSet", reason = "may be fxhash or siphash, depending on the feature, stay flexible" }, + { path = "std::collections::Vec", reason = "we generally want to use bumpalos collections" }, + { path = "std::boxed::Box", reason = "we generally want to use bumpalos allocation" }, ] diff --git a/src/lex.rs b/src/lex.rs index 6ab3a9b..aceba87 100644 --- a/src/lex.rs +++ b/src/lex.rs @@ -104,7 +104,7 @@ pub struct Lexer<'code> { } impl<'code> Lexer<'code> { - pub fn lex(code: &'code str) -> Self { + pub fn new(code: &'code str) -> Self { Self { code: code.char_indices().peekable(), src: code, @@ -416,7 +416,7 @@ mod test { type StdString = std::string::String; fn lex_types(str: &str) -> Vec { - let lexer = Lexer::lex(str); + let lexer = Lexer::new(str); lexer.map(|token| token.unwrap().kind).collect::>() } diff --git a/src/lib.rs b/src/lib.rs index b632666..f40facc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,14 +10,14 @@ mod value; use crate::ast::Program; use bumpalo::Bump; + pub use lex::*; pub use parse::*; pub fn run_program(program: &str) { - let lexer = lex::Lexer::lex(program); - let ast_alloc = Bump::new(); + let lexer = lex::Lexer::new(program); let ast = parse::parse(lexer, &ast_alloc); match ast {