-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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: add to_string to numbers #19119
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Skipped Deployments
|
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.
Thank you for this! Left a note on avoiding duplicates
@@ -57,6 +59,19 @@ module std::u16 { | |||
std::macros::num_sqrt!<u16, u32>(x, 16) | |||
} | |||
|
|||
public fun to_string(mut value: u16): String { |
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.
Make it a macro similar to other functions in uN modules.
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.
Generally looks great, thank you so much!
Let's make a macro as @damirka suggests, and let's add a few more interesting test cases
fixed, sorry for not paying attention to the new implementation! |
crates/sui-framework/packages/move-stdlib/tests/integer_tests.move
Outdated
Show resolved
Hide resolved
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.
Looking better! Please, also these two commands:
cargo build -p sui-framework
./scripts/update-all-snapshots.sh
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.
LGTM, and all checks are green! Thank you @thounyy for this one!
This reverts commit df95820.
## Description Adds `to_string` to integer modules (`u8`->`u256`) ## Test plan Features tests. --- ## Release notes * unsigned integers now support `.to_string()` methods, for example `10u8.to_string()` is the same as `b"10".to_string()` - [x] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API:
## Description Adds `to_string` to integer modules (`u8`->`u256`) ## Test plan Features tests. --- ## Release notes * unsigned integers now support `.to_string()` methods, for example `10u8.to_string()` is the same as `b"10".to_string()` - [x] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API:
Description
Adds
to_string
to integer modules (u8
->u256
)Test plan
Features tests.
Release notes
unsigned integers now support
.to_string()
methods, for example10u8.to_string()
is the same asb"10".to_string()