diff options
author | Alan Somers <asomers@gmail.com> | 2021-06-12 18:00:29 -0600 |
---|---|---|
committer | Alan Somers <asomers@gmail.com> | 2021-06-12 18:06:16 -0600 |
commit | 4da2e02482a63daf286b3658fbf8ec15906c9c72 (patch) | |
tree | 5de175a106aaec4ea6ac6df9d1d6b7d2bae3504a | |
parent | 5494b74b4e7b012dc09a366ecb73e5de53486fd3 (diff) | |
download | nix-4da2e02482a63daf286b3658fbf8ec15906c9c72.zip |
Errno aliases are now associated consts of the Errno type.
Previously they had to be consts in the errno module, because associated
consts weren't supported until Rust 1.20.0. Now that they're associated
consts, they can be used interchangeably with regular Errno enum
variants.
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | src/errno.rs | 56 |
2 files changed, 39 insertions, 20 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b7a3ecd9..143d85de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,9 @@ This project adheres to [Semantic Versioning](https://semver.org/). (#[1440](https://github.com/nix-rust/nix/pull/1440)) - Minimum supported Rust version is now 1.41.0. ([#1440](https://github.com/nix-rust/nix/pull/1440)) +- Errno aliases are now associated consts on `Errno`, instead of consts in the + `errno` module.` + (#[1452](https://github.com/nix-rust/nix/pull/1452)) ### Fixed - Allow `sockaddr_ll` size, as reported by the Linux kernel, to be smaller then it's definition diff --git a/src/errno.rs b/src/errno.rs index d8cc626f..2514dab3 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -843,9 +843,11 @@ mod consts { EHWPOISON = libc::EHWPOISON, } - pub const EWOULDBLOCK: Errno = Errno::EAGAIN; - pub const EDEADLOCK: Errno = Errno::EDEADLK; - pub const ENOTSUP: Errno = Errno::EOPNOTSUPP; + impl Errno { + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + pub const EDEADLOCK: Errno = Errno::EDEADLK; + pub const ENOTSUP: Errno = Errno::EOPNOTSUPP; + } pub fn from_i32(e: i32) -> Errno { use self::Errno::*; @@ -1103,9 +1105,11 @@ mod consts { EQFULL = libc::EQFULL, } - pub const ELAST: Errno = Errno::EQFULL; - pub const EWOULDBLOCK: Errno = Errno::EAGAIN; - pub const EDEADLOCK: Errno = Errno::EDEADLK; + impl Errno { + pub const ELAST: Errno = Errno::EQFULL; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + pub const EDEADLOCK: Errno = Errno::EDEADLK; + } pub fn from_i32(e: i32) -> Errno { use self::Errno::*; @@ -1326,9 +1330,11 @@ mod consts { EOWNERDEAD = libc::EOWNERDEAD, } - pub const ELAST: Errno = Errno::EOWNERDEAD; - pub const EWOULDBLOCK: Errno = Errno::EAGAIN; - pub const EDEADLOCK: Errno = Errno::EDEADLK; + impl Errno { + pub const ELAST: Errno = Errno::EOWNERDEAD; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + pub const EDEADLOCK: Errno = Errno::EDEADLK; + } pub fn from_i32(e: i32) -> Errno { use self::Errno::*; @@ -1538,10 +1544,12 @@ mod consts { EASYNC = libc::EASYNC, } - pub const ELAST: Errno = Errno::EASYNC; - pub const EWOULDBLOCK: Errno = Errno::EAGAIN; - pub const EDEADLOCK: Errno = Errno::EDEADLK; - pub const EOPNOTSUPP: Errno = Errno::ENOTSUP; + impl Errno { + pub const ELAST: Errno = Errno::EASYNC; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + pub const EDEADLOCK: Errno = Errno::EDEADLK; + pub const EOPNOTSUPP: Errno = Errno::ENOTSUP; + } pub fn from_i32(e: i32) -> Errno { use self::Errno::*; @@ -1750,8 +1758,10 @@ mod consts { EPROTO = libc::EPROTO, } - pub const ELAST: Errno = Errno::ENOTSUP; - pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + impl Errno { + pub const ELAST: Errno = Errno::ENOTSUP; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + } pub fn from_i32(e: i32) -> Errno { use self::Errno::*; @@ -1961,8 +1971,10 @@ mod consts { EPROTO = libc::EPROTO, } - pub const ELAST: Errno = Errno::ENOTSUP; - pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + impl Errno { + pub const ELAST: Errno = Errno::ENOTSUP; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + } pub fn from_i32(e: i32) -> Errno { use self::Errno::*; @@ -2162,7 +2174,9 @@ mod consts { EPROTO = libc::EPROTO, } - pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + impl Errno { + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + } pub fn from_i32(e: i32) -> Errno { use self::Errno::*; @@ -2387,8 +2401,10 @@ mod consts { ESTALE = libc::ESTALE, } - pub const ELAST: Errno = Errno::ESTALE; - pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + impl Errno { + pub const ELAST: Errno = Errno::ESTALE; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + } pub fn from_i32(e: i32) -> Errno { use self::Errno::*; |