alamb commented on code in PR #6372:
URL: https://github.com/apache/arrow-rs/pull/6372#discussion_r1750327558
##########
arrow-array/src/builder/generic_bytes_builder.rs:
##########
@@ -227,30 +243,51 @@ impl<T: ByteArrayType, V: AsRef<T::Native>>
Extend<Option<V>> for GenericByteBui
/// Values can be appended using [`GenericByteBuilder::append_value`], and
nulls with
/// [`GenericByteBuilder::append_null`].
///
-/// Additionally, implements [`std::fmt::Write`] with any written data
included in the next
-/// appended value. This allows use with [`std::fmt::Display`] without
intermediate allocations
+/// This builder also implements [`std::fmt::Write`] with any written data
+/// included in the next appended value. This allows using
[`std::fmt::Display`]
+/// with standard Rust idioms like `write!` and `writeln!` to write data
+/// directly to the builder without intermediate allocations.
+///
+/// # Example writing strings with `append_value`
Review Comment:
This style is by far the most common in DataFusion (and I think in other
systems)
##########
arrow-array/src/builder/generic_bytes_builder.rs:
##########
@@ -227,30 +243,51 @@ impl<T: ByteArrayType, V: AsRef<T::Native>>
Extend<Option<V>> for GenericByteBui
/// Values can be appended using [`GenericByteBuilder::append_value`], and
nulls with
/// [`GenericByteBuilder::append_null`].
///
-/// Additionally, implements [`std::fmt::Write`] with any written data
included in the next
-/// appended value. This allows use with [`std::fmt::Display`] without
intermediate allocations
+/// This builder also implements [`std::fmt::Write`] with any written data
Review Comment:
The point of the PR was to make this feature clearer
##########
arrow-array/src/builder/generic_bytes_builder.rs:
##########
@@ -227,30 +243,51 @@ impl<T: ByteArrayType, V: AsRef<T::Native>>
Extend<Option<V>> for GenericByteBui
/// Values can be appended using [`GenericByteBuilder::append_value`], and
nulls with
/// [`GenericByteBuilder::append_null`].
///
-/// Additionally, implements [`std::fmt::Write`] with any written data
included in the next
-/// appended value. This allows use with [`std::fmt::Display`] without
intermediate allocations
+/// This builder also implements [`std::fmt::Write`] with any written data
+/// included in the next appended value. This allows using
[`std::fmt::Display`]
+/// with standard Rust idioms like `write!` and `writeln!` to write data
+/// directly to the builder without intermediate allocations.
+///
+/// # Example writing strings with `append_value`
+/// ```
+/// # use arrow_array::builder::GenericStringBuilder;
+/// let mut builder = GenericStringBuilder::<i32>::new();
+///
+/// // Write one string value
+/// builder.append_value("foobarbaz");
+///
+/// // Write a second string
+/// builder.append_value("v2");
+///
+/// let array = builder.finish();
+/// assert_eq!(array.value(0), "foobarbaz");
+/// assert_eq!(array.value(1), "v2");
+/// ```
+///
+/// # Example incrementally writing strings with `std::fmt::Write`
Review Comment:
This style could be used for certain kernels, so I think it is better t have
it as its own example
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]