Skip to content

Commit 54f30f3

Browse files
committed
Remove cairo-lang-runner form shared crate
commit-id:c843cf8e
1 parent f9de18e commit 54f30f3

File tree

3 files changed

+13
-29
lines changed

3 files changed

+13
-29
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/shared/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ version = "0.1.0"
44
edition.workspace = true
55

66
[dependencies]
7+
starknet_api.workspace = true
78
anyhow.workspace = true
89
starknet-types-core.workspace = true
9-
cairo-lang-runner.workspace = true
1010
console.workspace = true
1111
semver.workspace = true
1212
starknet.workspace = true

crates/shared/src/utils.rs

+11-27
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,30 @@
1-
use cairo_lang_runner::casm_run::format_next_item;
1+
use starknet_api::execution_utils::format_panic_data;
22
use starknet_types_core::felt::Felt;
33

4-
/// Helper function to build readable text from a run data.
4+
/// Helper function to build readable text from run data.
55
#[must_use]
66
pub fn build_readable_text(data: &[Felt]) -> Option<String> {
7-
let mut data_iter = data.iter().copied();
8-
let mut items = Vec::new();
9-
10-
while let Some(item) = format_next_item(&mut data_iter) {
11-
items.push(item.quote_if_string());
12-
}
13-
14-
if items.is_empty() {
7+
if data.is_empty() {
158
return None;
169
}
1710

18-
let string = if let [item] = &items[..] {
19-
item.clone()
20-
} else {
21-
format!("({})", items.join(", "))
22-
};
11+
let string = format_panic_data(data);
2312

2413
let mut result = indent_string(&format!("\n{string}"));
2514
result.push('\n');
2615
Some(result)
2716
}
2817

2918
fn indent_string(string: &str) -> String {
30-
let mut modified_string = string.to_string();
31-
let trailing_newline = if string.ends_with('\n') {
32-
modified_string.pop();
33-
true
34-
} else {
35-
false
36-
};
19+
let without_trailing = string.strip_suffix('\n').unwrap_or(string);
20+
let indented = without_trailing.replace('\n', "\n ");
21+
let should_append_newline = string.ends_with('\n');
3722

38-
modified_string = modified_string.replace('\n', "\n ");
39-
if trailing_newline {
40-
modified_string.push('\n');
23+
if should_append_newline {
24+
format!("{indented}\n")
25+
} else {
26+
indented
4127
}
42-
43-
modified_string
4428
}
4529

4630
#[cfg(test)]

0 commit comments

Comments
 (0)