Document an unwrap
This commit is contained in:
parent
abacaf2aef
commit
2e53625421
1 changed files with 4 additions and 1 deletions
|
@ -265,7 +265,10 @@ macro_rules! try_from {
|
||||||
type Error = Size;
|
type Error = Size;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn try_from(int: ScalarInt) -> Result<Self, Size> {
|
fn try_from(int: ScalarInt) -> Result<Self, Size> {
|
||||||
int.to_bits(Size::from_bytes(std::mem::size_of::<$ty>())).map(|u| u.try_into().unwrap())
|
// The `unwrap` cannot fail because to_bits (if it succeeds)
|
||||||
|
// is guaranteed to return a value that fits into the size.
|
||||||
|
int.to_bits(Size::from_bytes(std::mem::size_of::<$ty>()))
|
||||||
|
.map(|u| u.try_into().unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue