From a4c8095a9bb46a5a8f6a058eab51ee23285312f9 Mon Sep 17 00:00:00 2001 From: vic1707 <28602203+vic1707@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:49:27 +0200 Subject: [PATCH] consolidate macros in one file --- .cargo/config.toml | 2 +- src/lib.rs | 4 ++-- src/macros.rs | 20 ++++++++++++++++++++ src/parser.rs | 3 +-- src/trust_me.rs | 8 -------- src/yeet.rs | 11 ----------- 6 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 src/macros.rs delete mode 100644 src/trust_me.rs delete mode 100644 src/yeet.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index c32abbc..9aed78d 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -12,7 +12,7 @@ rustflags = [ "-Aclippy::question_mark_used", # convenience "-Aclippy::single_call_fn", # function only called once "-Aclippy::single_char_lifetime_names", # common practice to use 'a, to remove ? - "-Aclippy::pub-with-shorthand", # export of `yeet!` macro is problematic with this lint + "-Aclippy::pub-with-shorthand", # pub() instead of pub(in ) ## Must remove ## "-Aclippy::missing_docs_in_private_items", "-Aclippy::missing-errors-doc", diff --git a/src/lib.rs b/src/lib.rs index 235de40..631b391 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,10 +2,10 @@ #![allow(clippy::pub_use)] /* Modules */ mod element; +#[doc(hidden)] +mod macros; mod parser; mod token; -mod trust_me; -mod yeet; /* Tests */ #[cfg(test)] mod tests; diff --git a/src/macros.rs b/src/macros.rs new file mode 100644 index 0000000..b9141d1 --- /dev/null +++ b/src/macros.rs @@ -0,0 +1,20 @@ +#[doc(hidden)] +macro_rules! trust_me { + ($($t:tt)*) => { + unsafe { $($t)* } + } +} + +pub(crate) use trust_me; + +#[doc(hidden)] +macro_rules! yeet { + () => { + return None + }; + ($err:expr) => { + return Err($err) + }; +} + +pub(crate) use yeet; diff --git a/src/parser.rs b/src/parser.rs index e3cc0fe..f466608 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -4,8 +4,7 @@ use core::str; use crate::{ element::{BinOp, Element, FunctionCall, UnOp}, token::{Identifier, Operator}, - trust_me::trust_me, - yeet::yeet, + macros::{trust_me, yeet}, }; /* Constants */ pub const NO_PERCEDENCE: usize = 0; diff --git a/src/trust_me.rs b/src/trust_me.rs deleted file mode 100644 index d5f5d14..0000000 --- a/src/trust_me.rs +++ /dev/null @@ -1,8 +0,0 @@ -#[doc(hidden)] -macro_rules! trust_me { - ($($t:tt)*) => { - unsafe { $($t)* } - } -} - -pub(super) use trust_me; diff --git a/src/yeet.rs b/src/yeet.rs deleted file mode 100644 index b78fec2..0000000 --- a/src/yeet.rs +++ /dev/null @@ -1,11 +0,0 @@ -#[doc(hidden)] -macro_rules! yeet { - () => { - return None - }; - ($err:expr) => { - return Err($err) - }; -} - -pub(super) use yeet;