Skip to content

Commit

Permalink
2.0.1: is_would_block to be const fn
Browse files Browse the repository at this point in the history
  • Loading branch information
DoumanAsh committed Sep 6, 2020
1 parent 3936c80 commit 4d6f3ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "error-code"
version = "2.0.0"
version = "2.0.1"
authors = ["Douman <douman@gmx.se>"]
edition = "2018"
description = "Alternative Error for Rust"
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl ErrorCode<PosixCategory> {
///
///Under POSIX, it means either `EWOULDBLOCK` or `EAGAIN`, in some cases it can be the same
///error code.
pub fn is_would_block(self) -> bool {
pub const fn is_would_block(self) -> bool {
posix::is_would_block(self.code)
}
}
Expand All @@ -135,7 +135,7 @@ impl ErrorCode<SystemCategory> {
///Under POSIX, it means either `EWOULDBLOCK` or `EAGAIN`, in some cases it can be the same
///error code.
///In case of Windows, it is also `WSAEWOULDBLOCK`
pub fn is_would_block(self) -> bool {
pub const fn is_would_block(self) -> bool {
#[cfg(windows)]
{
if self.code == 10035 {
Expand Down
4 changes: 2 additions & 2 deletions src/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ pub struct PosixCategory;

#[cfg(target_os = "unknown")]
#[inline(always)]
pub fn is_would_block(_: i32) -> bool {
pub const fn is_would_block(_: i32) -> bool {
false
}

#[cfg(not(target_os = "unknown"))]
#[inline]
pub fn is_would_block(code: i32) -> bool {
pub const fn is_would_block(code: i32) -> bool {
code == libc::EWOULDBLOCK || code == libc::EAGAIN
}

Expand Down

0 comments on commit 4d6f3ee

Please sign in to comment.