This is an automated email from the ASF dual-hosted git repository.

Jefffrey pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new bfa90af98d seal ToByteSlice trait (#10701)
bfa90af98d is described below

commit bfa90af98dcd38de0ed1c3829ee3b83a7edb4390
Author: RIchard Baah <[email protected]>
AuthorDate: Sun Aug 16 22:13:01 2026 -0400

    seal ToByteSlice trait (#10701)
    
    # Which issue does this PR close?
    
    <!--
    We generally require a GitHub issue to be filed for all bug fixes and
    enhancements and this helps us generate change logs for our releases.
    You can link an issue to this PR using the GitHub syntax.
    -->
    
    - Closes #10252.
    
    # Rationale for this change
    
    see
    https://github.com/apache/arrow-rs/issues/10252#issuecomment-5085914318
    
    <!--
    Why are you proposing this change? If this is already explained clearly
    in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand
    your changes and offer better suggestions for fixes.
    -->
    
    # What changes are included in this PR?
    seal `toByteSlice`
    <!--
    There is no need to duplicate the description in the issue here but it
    is sometimes worth providing a summary of the individual changes in this
    PR.
    -->
    
    # Are these changes tested?
    n/a
    <!--
    We typically require tests for all PRs in order to:
    1. Prevent the code from being accidentally broken by subsequent changes
    2. Serve as another way to document the expected behavior of the code
    
    If tests are not included in your PR, please explain why (for example,
    are they covered by existing tests)?
    
    If this PR claims a performance improvement, please include evidence
    such as benchmark results.
    -->
    
    # Are there any user-facing changes?
    yes, users can no longer implement `ToByteSlice`.
    <!--
    If there are user-facing changes then we may require documentation to be
    updated before approving the PR.
    
    If there are any breaking changes to public APIs, please call them out.
    -->
---
 arrow-buffer/src/native.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arrow-buffer/src/native.rs b/arrow-buffer/src/native.rs
index 68058a4eec..7939cb0ca6 100644
--- a/arrow-buffer/src/native.rs
+++ b/arrow-buffer/src/native.rs
@@ -22,6 +22,9 @@ mod private {
     pub trait Sealed {}
 }
 
+// Required so that `[T]` satisfies the `Sealed` supertrait of `ToByteSlice`.
+impl<T: ArrowNativeType> private::Sealed for [T] {}
+
 /// Trait expressing a Rust type that has the same in-memory representation as
 /// Arrow.
 ///
@@ -265,7 +268,7 @@ impl ArrowNativeType for IntervalDayTime {
 }
 
 /// Allows conversion from supported Arrow types to a byte slice.
-pub trait ToByteSlice {
+pub trait ToByteSlice: private::Sealed {
     /// Converts this instance into a byte slice
     fn to_byte_slice(&self) -> &[u8];
 }

Reply via email to