Skip to content

Commit

Permalink
fix(crosstarget-utils): fixes on regex and derive_more
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Oct 15, 2024
1 parent c5a6135 commit 6e54f4c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ tokio = { version = "1", features = [
"time",
] }
chrono = { version = "0.4.38", features = ["serde"] }
derive_more = "0.99.17"
user-facing-errors = { path = "./libs/user-facing-errors" }
uuid = { version = "1", features = ["serde", "v4", "v7", "js"] }
indoc = "2.0.1"
Expand Down
3 changes: 2 additions & 1 deletion libs/crosstarget-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
futures = "0.3"
derive_more.workspace = true
enumflags2.workspace = true
futures = "0.3"

[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion libs/crosstarget-utils/src/common/regex.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use derive_more::Display;

#[derive(Debug, Display)]
#[display("Regular expression error: {message}")]
#[display(fmt = "Regular expression error: {message}")]
pub struct RegExpError {
pub message: String,
}
Expand Down
9 changes: 3 additions & 6 deletions libs/crosstarget-utils/src/wasm/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ impl RegExpCompat for RegExp {
fn captures(&self, message: &str) -> Option<Vec<String>> {
let matches = self.inner.exec(message);
matches.map(|matches| {
let mut captures = Vec::new();
let mut captures: Vec<String> = Vec::new();
for i in 0..matches.length() {
let match_value = matches.get(i);

// We keep the same number of captures as the number of groups in the regex pattern,
// but we guarantee that the captures are always strings.
if match_value.is_string() {
captures.push(match_value.as_string().unwrap());
} else {
captures.push(String::new());
}
let capture: String = match_value.try_into().ok().unwrap_or_default();
captures.push(capture);
}
captures
})
Expand Down
2 changes: 1 addition & 1 deletion query-engine/connectors/mongodb-query-connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ uuid.workspace = true
indexmap.workspace = true
query-engine-metrics = { path = "../../metrics" }
cuid = { git = "https://github.com/prisma/cuid-rust", branch = "wasm32-support" }
derive_more = "0.99.17"
derive_more.workspace = true

[dependencies.query-structure]
path = "../../query-structure"
Expand Down

0 comments on commit 6e54f4c

Please sign in to comment.