/// Implements the `EncodeToWrite` trait for the `target_type`.
///
/// The `target_type` must also implement `EncodeToSlice` and have a relatively small maximum
/// encoded length (that will fit on the stack). The `encode_to_slice_unchecked` function is used
/// to encode the value to a stack buffer before it is flushed to the `Write`.