uniffi-rs
uniffi-rs copied to clipboard
Vec capacity can unnecessarily cause Rust panics when creating a `RustBuffer`.
We've run into an issue where passing a large enough bytes sequence into Rust will cause a panic in RustBuffer::from_vec due to the Vec's capacity exceeding i32::MAX. This is despite the length of the Vec being less than i32::MAX. Rust makes no guarantees about how the capacity of a Vec grows, but in our case, it has cut the effective max length by about half. It seems like we should try to shrink the size of the Vec before calling RustBuffer::from_vec as to prevent what should be valid data from panicking.