hsivonen / encoding_rs

A Gecko-oriented implementation of the Encoding Standard in Rust
https://docs.rs/encoding_rs/
Other
384 stars 55 forks source link

Why does `encoding_rs::mem::convert_latin1_to_utf8` panic instead of returning an Error? #106

Open nicmr opened 3 months ago

nicmr commented 3 months ago

encoding_rs::mem::convert_latin1_to_utf8 and similar functions panic instead of returning an error when the passed slice to write into is too small.

This immediately struck my as unidiomatic in Rust and effectively means I will have to use encoding_rs::mem::convert_latin1_to_utf8_partial instead and wrap it with my own error for ergonomic usage.

Is this behaviour required for abiding by encoding standard or was this decision made for a different reason? Sorry for my ignorance.