diff --git a/src/array/utf8/mutable.rs b/src/array/utf8/mutable.rs index d3fb8bdbc82..78cb9a65a97 100644 --- a/src/array/utf8/mutable.rs +++ b/src/array/utf8/mutable.rs @@ -25,12 +25,17 @@ pub struct MutableUtf8Array { impl From> for Utf8Array { fn from(other: MutableUtf8Array) -> Self { - Utf8Array::::from_data( - other.data_type, - other.offsets.into(), - other.values.into(), - other.validity.map(|x| x.into()), - ) + // Safety: + // `MutableUtf8Array` has the same invariants as `Utf8Array` and thus + // `Utf8Array` can be safely crated from `MutableUtf8Array` without checks. + unsafe { + Utf8Array::::from_data_unchecked( + other.data_type, + other.offsets.into(), + other.values.into(), + other.validity.map(|x| x.into()), + ) + } } }