Skip to content

Commit e975057

Browse files
committed
Clarify the text of some comments
1 parent f6a57c1 commit e975057

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: library/core/src/option.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ impl<T> Option<T> {
745745
/// It's guaranteed to be a multiple of alignment (so will always give a
746746
/// correctly-aligned location) and to be within the allocated object, so
747747
/// is valid to use with `offset` and to use for a zero-sized read.
748+
///
749+
/// FIXME: This is a horrible hack, but allows a nice optimization. It should
750+
/// be replaced with `offset_of!` once that works on enum variants.
748751
const SOME_BYTE_OFFSET_GUESS: isize = {
749752
let some_uninit = Some(mem::MaybeUninit::<T>::uninit());
750753
let payload_ref = some_uninit.as_ref().unwrap();
@@ -762,7 +765,8 @@ impl<T> Option<T> {
762765

763766
let max_offset = mem::size_of::<Self>() - mem::size_of::<T>();
764767
if offset as usize <= max_offset {
765-
// The offset is at least inside the object, so let's try it.
768+
// There's enough space after this offset for a `T` to exist without
769+
// overflowing the bounds of the object, so let's try it.
766770
offset
767771
} else {
768772
// The offset guess is definitely wrong, so use the address

0 commit comments

Comments
 (0)