-
Notifications
You must be signed in to change notification settings - Fork 553
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: support format!("{:x}") notation for hexadecimal formatting #6297
Conversation
8ec5a77
to
449ab33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 8 files at r1.
Reviewable status: 3 of 8 files reviewed, 4 unresolved discussions (waiting on @remybar)
Cargo.lock
line 241 at r1 (raw file):
] [[package]]
revert file.
corelib/src/fmt.cairo
line 320 at r1 (raw file):
> of LowerHex<T> { fn fmt(self: @T, ref f: Formatter) -> Result<(), Error> { f.buffer.append(@"0x");
shouldn't be part of it. same as rust.
Code quote:
f.buffer.append(@"0x");
crates/cairo-lang-semantic/src/inline_macros/write.rs
line 142 at r1 (raw file):
WriteMacro::NAME } }
run the same rust fmt as the CI.
(./script/rust_fmt.sh
)
Code quote:
fn get_macro_name(with_newline: bool) -> &'static str {
if with_newline {
WritelnMacro::NAME
} else {
WriteMacro::NAME
}
}
crates/cairo-lang-semantic/src/inline_macros/write.rs
line 527 at r1 (raw file):
} else { return Err("Unsupported formatting trait: only `Display` and `Debug` are supported"); };
Suggestion:
let fmt_type = match formatting_spec.as_str() {
"" => FormattingTrait::Display,
"?" => FormattingTrait::Debug,
"x" => FormattingTrait::LowerHex,
_ => return Err("Unsupported formatting trait: only `Display`, `Debug` and `LowerHex` are supported"),
};
bc28a98
to
c257cb4
Compare
Hi @orizi ! Thanks for the review. I did the required changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 4 files at r2.
Reviewable status: 4 of 8 files reviewed, 1 unresolved discussion (waiting on @remybar)
crates/cairo-lang-semantic/src/inline_macros/write.rs
line 527 at r1 (raw file):
} else { return Err("Unsupported formatting trait: only `Display` and `Debug` are supported"); };
why not match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please view at reviewable: https://reviewable.io/reviews/starkware-libs/cairo/6297#-
Reviewable status: 4 of 8 files reviewed, 1 unresolved discussion (waiting on @remybar)
c257cb4
to
0a5a716
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 4 of 8 files reviewed, 1 unresolved discussion (waiting on @remybar)
a discussion (no related file):
@gilbens-starkware for 2nd eye.
Because I didn't noticed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 4 of 8 files reviewed, 1 unresolved discussion (waiting on @orizi and @remybar)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 8 files at r1, 1 of 4 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @remybar)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @remybar)
0a5a716
to
43af87e
Compare
Head branch was pushed to by a user without write access
43af87e
to
de34984
Compare
de34984
to
0e9423e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @remybar)
Head branch was pushed to by a user without write access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r5.
Reviewable status: all files reviewed (commit messages unreviewed), all discussions resolved (waiting on @Arcticae, @Draggu, and @piotmag769)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @remybar)
Proposal for issue #6261.
This PR adds a
LowerHex
trait as existing in Rust, to be able to format integer values to hexadecimal using the{:x}
notation. Rust also provides aUpperHex
trait to format the string in upper case but I don't know if it's really useful.This PR also implements this trait for:
u8
tou256
),NonZero
ContractAddress
andClassHash
using the existinginto_felt252_based
module.This change is