Skip to content

Conversation

@alamb
Copy link

@alamb alamb commented Oct 24, 2025

This is a proposed simplification for the following PR (merging this PR will update that one):

I will comment inline about the rationale

)]
pub fn mutable_bitwise_bin_op_helper<F>(
left: &mut impl MutableOpsBufferSupportedLhs,
left: &mut MutableBuffer,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than hiding what is going on with pub/hidden traits, I think it is clearer to simply pass in the MutableBuffer here

If you accept this PR and #1 we can avoid the #allow about private bounds as well

/// The caller must ensure that any modifications to the buffer maintain the invariant
/// `self.len < buffer.len() / 8` (that is that the buffer has enough capacity to hold `self.len` bits).
#[inline]
pub unsafe fn mutable_buffer(&mut self) -> &mut MutableBuffer {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally think the code is much clearer and easier to understand if make a function that directly exposes the inner MutableBuffer (which is what the trait does) but mark it as unsafe, rather than relying on non public traits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant