You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cast_possible_wrap's docs currently have an explanation of why this isn't desirable, but do not give the user an alternative to use.
I'd like to suggest adding a mention of a safe method of converting between numeric types where the target is of a smaller size than the origin:
use std::convert::TryFrom;let max_u32 = u32::MAX;
i32::try_from(max_u32).ok()// None, due to `u32::MAX` not fitting in an `i32`let u32_value = 5_u32;
i32::try_from(u32_value).ok()// Some(5), since `5_u32` fits in an `i32`
Description
cast_possible_wrap
's docs currently have an explanation of why this isn't desirable, but do not give the user an alternative to use.I'd like to suggest adding a mention of a safe method of converting between numeric types where the target is of a smaller size than the origin:
Example Playground
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: