to_vec_with_capacity

Function to_vec_with_capacity 

Source
pub fn to_vec_with_capacity<T>(
    value: &T,
    capacity: usize,
) -> Result<Vec<u8>, JsonError>
where T: Serialize,
Expand description

Serialize a value to a JSON byte vector with pre-allocated capacity.

Use this when you have a good estimate of the output size to avoid reallocations.