Currently, we have methods like write_to and write_to_prefix return Option<()> in order to signal success or failure ("failure" here means that the provided bytes: &mut [u8] wasn't long enough). This breaks with the common Rust pattern, which would have these simply panic in this case.
In my opinion, it's preferable to avoid panicking when possible, so it's good to provide methods with this behavior. However, we could get the best of both worlds and be more consistent with Rust style by having methods like write_to panic, and introducing new methods like try_write_to which return Option<()>.
See also #188
Currently, we have methods like
write_toandwrite_to_prefixreturnOption<()>in order to signal success or failure ("failure" here means that the providedbytes: &mut [u8]wasn't long enough). This breaks with the common Rust pattern, which would have these simply panic in this case.In my opinion, it's preferable to avoid panicking when possible, so it's good to provide methods with this behavior. However, we could get the best of both worlds and be more consistent with Rust style by having methods like
write_topanic, and introducing new methods liketry_write_towhich returnOption<()>.See also #188