We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scarb fmt
Cairo version:
scarb 2.9.2+nightly-2025-01-01 (bb807b9e4 2025-01-01) cairo: 2.9.2 (9d2d903d3) sierra: 1.6.0
Current behavior:
Running scarb fmt to format code that contains a closure results in inconsistent formatting.
As can be seen in the Related code section, an example with 3 different closures is given, where:
_closure_returns_sum_as_usize
_closure_returns_bytearray
_closure_returns_sum_as_usize_but_with_a_much_longer_name
Running scarb fmt results in the following:
left: usize
Expected behavior:
Running scarb fmt should ideally have the same behavior as cargo fmt has (see Related code below).
cargo fmt
Steps to reproduce:
To reproduce the issue with scarb fmt:
scarb new closures_example
To verify how cargo fmt behaves:
cargo new rust_closures_example
Related code:
Before formatting:
fn main() { let _closure_returns_sum_as_usize = |left: usize, right: usize| -> usize { left + right }; let _closure_return_bytearray = |left: usize, right: usize| -> ByteArray { format!("{left}{right}") }; let _closure_returns_sum_as_usize_but_with_a_much_longer_name = |left: usize, right: usize| -> usize { left + right }; }
After formatting with scarb fmt:
If the same code is pasted into a Rust project, and formatted with cargo fmt:
Other information:
The text was updated successfully, but these errors were encountered:
https://reviewable.io/reviews/starkware-libs/cairo/7065
Sorry, something went wrong.
formatting is better now on main. not same as rust - but no reason for it to be exactly the same as rust.
gilbens-starkware
dean-starkware
Successfully merging a pull request may close this issue.
Bug Report
Cairo version:
Current behavior:
Running
scarb fmt
to format code that contains a closure results in inconsistent formatting.As can be seen in the Related code section, an example with 3 different closures is given, where:
_closure_returns_sum_as_usize
and_closure_returns_bytearray
have the same initial (pre-format) line length._closure_returns_sum_as_usize
and_closure_returns_sum_as_usize_but_with_a_much_longer_name
have the same function signatures.Running
scarb fmt
results in the following:_closure_returns_sum_as_usize
is left as-is._closure_returns_bytearray
is wrapped after theleft: usize
argument._closure_returns_sum_as_usize_but_with_a_much_longer_name
is wrapped after theleft: usize
argument.Expected behavior:
Running
scarb fmt
should ideally have the same behavior ascargo fmt
has (see Related code below).Steps to reproduce:
To reproduce the issue with
scarb fmt
:scarb new closures_example
.scarb fmt
.To verify how
cargo fmt
behaves:cargo new rust_closures_example
.cargo fmt
.Related code:
Before formatting:
After formatting with
scarb fmt
:If the same code is pasted into a Rust project, and formatted with
cargo fmt
:Other information:
The text was updated successfully, but these errors were encountered: