You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2025/01/01 14:25:10 UTC

(arrow-rs) branch main updated: Add doctest example for `Buffer::from_bytes` (#6920)

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

alamb 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 fbee05f22a Add doctest example for `Buffer::from_bytes` (#6920)
fbee05f22a is described below

commit fbee05f22a80d2e874ded122dce0efb36ef66c8a
Author: Kyle Barron <ky...@gmail.com>
AuthorDate: Wed Jan 1 06:25:04 2025 -0800

    Add doctest example for `Buffer::from_bytes` (#6920)
    
    * Add doctest example for
    
    * Remove typo
    
    * Update arrow-buffer/src/buffer/immutable.rs
    
    ---------
    
    Co-authored-by: Andrew Lamb <an...@nerdnetworks.org>
---
 arrow-buffer/src/buffer/immutable.rs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arrow-buffer/src/buffer/immutable.rs b/arrow-buffer/src/buffer/immutable.rs
index d0c8ffa397..cf1d6f3667 100644
--- a/arrow-buffer/src/buffer/immutable.rs
+++ b/arrow-buffer/src/buffer/immutable.rs
@@ -60,6 +60,14 @@ unsafe impl Sync for Buffer where Bytes: Sync {}
 
 impl Buffer {
     /// Auxiliary method to create a new Buffer
+    ///
+    /// This can be used with a [`bytes::Bytes`] via `into()`:
+    ///
+    /// ```
+    /// # use arrow_buffer::Buffer;
+    /// let bytes = bytes::Bytes::from_static(b"foo");
+    /// let buffer = Buffer::from_bytes(bytes.into());
+    /// ```
     #[inline]
     pub fn from_bytes(bytes: Bytes) -> Self {
         let length = bytes.len();