-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
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
feat: improve array formatting #6448
Comments
+1 |
I feel like your desired output as it is, is not well defined, as each row in the array does not span the entire line. If we'll break each line once it reached the full length of the we'll have something like: #[test]
fn test_u256_to_be_bytes_full() {
let input: u256 = 0xf432156278901234deadbeefcafebabe0123456789abcdef0fedcba987654321;
let res: Span<u8> = input.to_be_bytes();
assert_eq!(
res,
[
0xf4, 0x32, 0x15, 0x62, 0x78, 0x90, 0x12, 0x34, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe,
0xba, 0xbe, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x0f, 0xed, 0xcb, 0xa9,
0x87, 0x65, 0x43, 0x21
]
.span()
);
} Which is probably what we'll end up doing. Unrelated to this change, if you still wish to organise the array in a matrix like shape, you can make the formatter skip this statement using #[test]
fn test_u256_to_be_bytes_full() {
let input: u256 = 0xf432156278901234deadbeefcafebabe0123456789abcdef0fedcba987654321;
let res: Span<u8> = input.to_be_bytes();
#[cairofmt::skip]
assert_eq!(
res,
[
0xf4, 0x32, 0x15, 0x62, 0x78, 0x90, 0x12, 0x34,
0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0xba, 0xbe,
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
0x0f, 0xed, 0xcb, 0xa9, 0x87, 0x65, 0x43, 0x21
]
.span()
);
} |
Sure, that's fine for me, I just wanted something that was not one element per line 👍 |
It would be nice to format arrays enabling multiple values per line.
Current:
Desired:
The text was updated successfully, but these errors were encountered: