Skip to content

Commit c71ad9a

Browse files
committed
Fixed formatting, inline, and conversions
1 parent 7bb743b commit c71ad9a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/error.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const BLOCK_SIZE: u32 = 1 << 16;
2424

2525
impl Error {
2626
/// Create a new error from a raw OS error number (errno).
27+
#[inline]
2728
pub fn from_os_error(errno: i32) -> Self {
2829
assert!(errno > 0);
2930
Self(NonZeroU32::new(errno as u32).unwrap())
@@ -32,9 +33,10 @@ impl Error {
3233
/// Crate a custom error in the provided block (group of 2^16 error codes).
3334
/// The provided block must not be negative, and block 0 is reserved for
3435
/// custom errors in the `getrandom` crate.
36+
#[inline]
3537
pub fn custom_error(block: i16, code: u16) -> Self {
3638
assert!(block >= 0);
37-
let n = CUSTOM_START + (block as u32) * BLOCK_SIZE + (code as u32);
39+
let n = CUSTOM_START + (block as u16 as u32) * BLOCK_SIZE + (code as u32);
3840
Self(NonZeroU32::new(n).unwrap())
3941
}
4042

@@ -43,6 +45,7 @@ impl Error {
4345
/// This method is identical to `std::io::Error::raw_os_error()`, except
4446
/// that it works in `no_std` contexts. If this method returns `None`, the
4547
/// error value can still be formatted via the `Diplay` implementation.
48+
#[inline]
4649
pub fn raw_os_error(&self) -> Option<i32> {
4750
self.try_os_error().ok()
4851
}
@@ -51,6 +54,7 @@ impl Error {
5154
///
5255
/// This code can either come from the underlying OS, or be a custom error.
5356
/// Use [`raw_os_error()`] to disambiguate.
57+
#[inline]
5458
pub fn code(&self) -> NonZeroU32 {
5559
self.0
5660
}

0 commit comments

Comments
 (0)