solana_sdk::borsh1

Function try_from_slice_unchecked

Source
pub fn try_from_slice_unchecked<T>(data: &[u8]) -> Result<T, Error>
Expand description

Deserializes without checking that the entire slice has been consumed

Normally, try_from_slice checks the length of the final slice to ensure that the deserialization uses up all of the bytes in the slice.

Note that there is a potential issue with this function. Any buffer greater than or equal to the expected size will properly deserialize. For example, if the user passes a buffer destined for a different type, the error won’t get caught as easily.