Appends the string representation of each element in a leaf (non-list) array to `w`, separated by `delimiter`. Null elements are rendered using `null_string` if provided, or skipped otherwise. The `append` closure controls how each non-null element is written.
(
w: &mut W,
arr: &'a A,
delimiter: &str,
null_string: Option<&str>,
first: &mut bool,
append: impl Fn(&mut W, T) -> fmt::Result,
)
| 750 | /// using `null_string` if provided, or skipped otherwise. The `append` |
| 751 | /// closure controls how each non-null element is written. |
| 752 | fn write_leaf_to_string<'a, W: Write, A, T>( |
| 753 | w: &mut W, |
| 754 | arr: &'a A, |
| 755 | delimiter: &str, |
| 756 | null_string: Option<&str>, |
| 757 | first: &mut bool, |
| 758 | append: impl Fn(&mut W, T) -> fmt::Result, |
| 759 | ) -> Result<()> |
| 760 | where |
| 761 | &'a A: IntoIterator<Item = Option<T>>, |
| 762 | { |
| 763 | for x in arr { |
| 764 | // Skip nulls when no null_string is provided |
| 765 | if x.is_none() && null_string.is_none() { |
| 766 | continue; |
| 767 | } |
| 768 | |
| 769 | if *first { |
| 770 | *first = false; |
| 771 | } else { |
| 772 | w.write_str(delimiter)?; |
| 773 | } |
| 774 | |
| 775 | match x { |
| 776 | Some(x) => append(w, x)?, |
| 777 | None => w.write_str(null_string.unwrap())?, |
| 778 | } |
| 779 | } |
| 780 | Ok(()) |
| 781 | } |
| 782 | |
| 783 | trait StringArrayBuilderType: ArrayBuilder { |
| 784 | fn append_value(&mut self, val: &str); |