diff --git a/src/array/string.rs b/src/array/string.rs index 051a43b9..65ed4207 100644 --- a/src/array/string.rs +++ b/src/array/string.rs @@ -58,14 +58,17 @@ where } } -impl<'a, OffsetItem: OffsetElement, Buffer: BufferType> Extend> +impl<'a, T: ?Sized, OffsetItem: OffsetElement, Buffer: BufferType> Extend> for StringArray where + T: AsRef, VariableSizeBinaryArray: Extend>, { - fn extend>>(&mut self, iter: I) { - self.0 - .extend(iter.into_iter().map(|opt| opt.map(str::as_bytes))); + fn extend>>(&mut self, iter: I) { + self.0.extend( + iter.into_iter() + .map(|opt| opt.map(|item| item.as_ref().as_bytes())), + ); } } @@ -101,23 +104,33 @@ where } } -impl<'a, OffsetItem: OffsetElement, Buffer: BufferType> FromIterator<&'a str> +impl<'a, T: ?Sized, OffsetItem: OffsetElement, Buffer: BufferType> FromIterator<&'a T> for StringArray where + T: AsRef, VariableSizeBinaryArray: FromIterator<&'a [u8]>, { - fn from_iter>(iter: I) -> Self { - Self(iter.into_iter().map(str::as_bytes).collect()) + fn from_iter>(iter: I) -> Self { + Self( + iter.into_iter() + .map(|item| item.as_ref().as_bytes()) + .collect(), + ) } } -impl<'a, OffsetItem: OffsetElement, Buffer: BufferType> FromIterator> +impl<'a, T: ?Sized, OffsetItem: OffsetElement, Buffer: BufferType> FromIterator> for StringArray where + T: AsRef, VariableSizeBinaryArray: FromIterator>, { - fn from_iter>>(iter: I) -> Self { - Self(iter.into_iter().map(|x| x.map(str::as_bytes)).collect()) + fn from_iter>>(iter: I) -> Self { + Self( + iter.into_iter() + .map(|x| x.map(|item| item.as_ref().as_bytes())) + .collect(), + ) } }