-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Functionality for int_format_into
for integer types
#138338
base: master
Are you sure you want to change the base?
Functionality for int_format_into
for integer types
#138338
Conversation
Failed to set assignee to
|
@rustbot author |
This comment has been minimized.
This comment has been minimized.
d247480
to
dcb7e5d
Compare
This comment has been minimized.
This comment has been minimized.
dcb7e5d
to
cdd0823
Compare
This comment has been minimized.
This comment has been minimized.
cdd0823
to
a8968ea
Compare
This comment has been minimized.
This comment has been minimized.
a8968ea
to
e1d3241
Compare
This comment has been minimized.
This comment has been minimized.
e1d3241
to
ab8dd05
Compare
This comment has been minimized.
This comment has been minimized.
ab8dd05
to
890aaf1
Compare
This comment has been minimized.
This comment has been minimized.
890aaf1
to
8a6b99b
Compare
This comment has been minimized.
This comment has been minimized.
8a6b99b
to
0b924f5
Compare
This comment has been minimized.
This comment has been minimized.
0b924f5
to
4d0187e
Compare
This comment has been minimized.
This comment has been minimized.
4d0187e
to
4a67fb1
Compare
This comment has been minimized.
This comment has been minimized.
4a67fb1
to
2c1eba8
Compare
This comment has been minimized.
This comment has been minimized.
2c1eba8
to
d5834e9
Compare
b378b05
to
177df1d
Compare
@rustbot label -O-hermit -O-SGX -O-solid -O-wasi -O-wasm -O-windows -O-unix |
I was able to gain more clarity on what was needed, and I've moved the updates to the Primarily I've broken down Sorry for the long history in this PR. Please let me know if this looks good. |
int_format_into
for integer typesint_format_into
for integer types
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 working on this! The bird's eye view of the diff is now basically what I'd expect. I left some smaller comments I've noticed while scrolling through. I don't expect I'll have the time to review the implementation details as carefully as unsafe code deserves, so please work out those details with a reviewer who actually has permissions on this repository.
library/core/src/fmt/num_buffer.rs
Outdated
pub fn len(&self) -> usize { | ||
BUF_SIZE | ||
} | ||
|
||
/// Extracts a slice of the contents of the buffer. | ||
/// `index` must be bounds-checked before calling this function. | ||
/// | ||
/// SAFETY: `index` is bound-checked by the caller. | ||
#[unstable(feature = "int_format_into", issue = "138215")] | ||
pub unsafe fn extract<I>(&self, index: I) -> &I::Output | ||
where | ||
I: SliceIndex<[MaybeUninit<u8>]>, | ||
{ | ||
// SAFETY: `index` is bound-checked by the caller. | ||
unsafe { self.contents.get_unchecked(index) } | ||
} | ||
|
||
/// Returns a mutable pointer pointing to the start of the buffer. | ||
#[unstable(feature = "int_format_into", issue = "138215")] | ||
pub fn extract_start_mut_ptr(&mut self) -> *mut u8 { | ||
MaybeUninit::slice_as_mut_ptr(&mut self.contents) | ||
} | ||
|
||
/// Writes data at index `offset` of the buffer. | ||
/// | ||
/// SAFETY: `offset` is bound-checked by the caller | ||
#[unstable(feature = "int_format_into", issue = "138215")] | ||
pub unsafe fn write(&mut self, offset: usize, data: u8) { |
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.
Likewise, none of these methods should be public I think. Or, if they need to be public e.g. for unit tests of the standard library, they should be behind a perma-unstable "for internal use only" feature gate, not tied to int_format_into
/ #138215.
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.
Other than the new
function, I don't see usage of the other functions in other crates.
Thank you for suggesting me.
177df1d
to
e57b53c
Compare
I must thank you for patiently going through my updates multiple times. There was a lot for me to learn. |
This comment has been minimized.
This comment has been minimized.
e57b53c
to
d887240
Compare
This comment has been minimized.
This comment has been minimized.
I'm going to re-roll to get someone hopefully more familiar with the formatting stuff. |
d887240
to
2e18654
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
ACP approval: rust-lang/libs-team#546 (comment)
Context
fmt
.NumBuffer
type to help with this process.Associated Issue
r? @hanna-kruppe