commit e3664f1473a613d193cb825333988a4bef5d8379
parent 08fa34eb61b2f72f15d58690fbbe6a04938aa2d5
Author: donicrosby <donicrosby1995@gmail.com>
Date: Sat, 23 Oct 2021 13:51:36 -0400
Updated lazy_static placement
Diffstat:
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/mrsbfh-macros/src/lib.rs b/mrsbfh-macros/src/lib.rs
@@ -333,13 +333,15 @@ pub fn commands(_: TokenStream, input: TokenStream) -> TokenStream {
let cloned_config = self.config.clone();
let cloned_client = self.client.clone();
tokio::spawn(async move {
- let whitespace_deduplicator_magic = regex::Regex::new(r"\s+").unwrap();
- let command_matcher_magic = regex::Regex::new(r"!([\w-]+)").unwrap();
- let normalized_body = whitespace_deduplicator_magic.replace_all(&msg_body, " ");
+ lazy_static! {
+ static ref WHITESPACE_DEDUPLICATOR_MAGIC: regex::Regex = regex::Regex::new(r"\s+").unwrap();
+ static ref COMMAND_MATCHER_MAGIC: regex::Regex = regex::Regex::new(r"!([\w-]+)").unwrap();
+ }
+ let normalized_body = WHITESPACE_DEDUPLICATOR_MAGIC.replace_all(&msg_body, " ");
let mut split = msg_body.split_whitespace();
let command_raw = split.next().expect("This is not a command").to_lowercase();
- let command = command_matcher_magic.captures(command_raw.as_str())
+ let command = COMMAND_MATCHER_MAGIC.captures(command_raw.as_str())
.map_or(String::new(), |caps| {
caps.get(1)
.map_or(String::new(),
diff --git a/mrsbfh/Cargo.toml b/mrsbfh/Cargo.toml
@@ -21,7 +21,7 @@ thiserror = "1.0"
# Command macros
mrsbfh-macros = {path = "../mrsbfh-macros", optional = true}
-tokio = { version = "1", features = ["full"] }
+tokio = { version = "1", features =["rt", "rt-multi-thread", "macros"]}
tracing = "0.1"
serde = "1.0"
@@ -32,6 +32,7 @@ pulldown-cmark = "0.8.0" # For generating the help text
regex = "1.4"
async-trait = "0.1"
+lazy_static = "1"
[features]
default = ["macros"]
diff --git a/mrsbfh/src/lib.rs b/mrsbfh/src/lib.rs
@@ -67,6 +67,7 @@ impl MatrixMessageExt for Sender {
}
}
+pub use lazy_static::lazy_static;
pub use pulldown_cmark;
pub use serde_yaml;
pub use tokio;