I have a use case that requires me to construct an ArrayString<CAP> from a UTF-8 ArrayVec<u8, CAP>. For Vec<u8> to String, I would use String::from_utf8, but the closest equivalent is ArrayString::from_byte_string, which won't work if the ArrayVec is not full. Therefore, I'd like to request a method such as:
impl<const CAP: usize> ArrayString<CAP> {
pub fn from_utf8(vec: ArrayVec<u8, CAP>) -> Result<ArrayString<CAP>, FromUtf8Error<CAP>>;
}
This specific design entails adding a struct FromUtf8Error<const CAP: usize>, which would mimic std::string::FromUtf8Error; with that said, I'm not fussed about the specifics as long as I can (fallibly) get an ArrayString<CAP> from an ArrayVec<u8, CAP>.
Also, I have a workaround, so I'm not looking for solutions; it's just less elegant (and std-like) than I'd like.
I have a use case that requires me to construct an
ArrayString<CAP>from a UTF-8ArrayVec<u8, CAP>. ForVec<u8>toString, I would useString::from_utf8, but the closest equivalent isArrayString::from_byte_string, which won't work if theArrayVecis not full. Therefore, I'd like to request a method such as:This specific design entails adding a
struct FromUtf8Error<const CAP: usize>, which would mimicstd::string::FromUtf8Error; with that said, I'm not fussed about the specifics as long as I can (fallibly) get anArrayString<CAP>from anArrayVec<u8, CAP>.Also, I have a workaround, so I'm not looking for solutions; it's just less elegant (and
std-like) than I'd like.