let (encoded, _, unencodable) = encoding.encode(s);
if unencodable {
let mut encoder = encoding.new_encoder();
- let mut buf =
- Vec::with_capacity(encoder.max_buffer_length_from_utf8_without_replacement(s.len()).unwrap());
+ let mut buf = Vec::with_capacity(
+ encoder
+ .max_buffer_length_from_utf8_without_replacement(s.len())
+ .unwrap(),
+ );
let EncoderResult::Unmappable(c) = encoder
.encode_from_utf8_to_vec_without_replacement(s, &mut buf, true)
.0
else {
unreachable!();
};
- return Err(Error::NotEncodable { id: s.into(), encoding: encoding.name(), c });
+ return Err(Error::NotEncodable {
+ id: s.into(),
+ encoding: encoding.name(),
+ c,
+ });
}
if encoded.len() > Self::MAX_LEN {
- return Err(Error::TooLong { id: s.into(), length: encoded.len(), encoding: encoding.name(), max: Self::MAX_LEN });
+ return Err(Error::TooLong {
+ id: s.into(),
+ length: encoded.len(),
+ encoding: encoding.name(),
+ max: Self::MAX_LEN,
+ });
}
Ok(Identifier(s.into()))
}