diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/errno.rs | 18 | ||||
-rw-r--r-- | src/sys/signal.rs | 2 | ||||
-rw-r--r-- | src/sys/socket/addr.rs | 8 |
4 files changed, 15 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c2037cb5..47cd139e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). - Many more functions, mostly contructors, are now `const`. (#[1476](https://github.com/nix-rust/nix/pull/1476)) + (#[1492](https://github.com/nix-rust/nix/pull/1492)) - `sys::event::KEvent::filter` now returns a `Result` instead of being infalliable. The only cases where it will now return an error are cases diff --git a/src/errno.rs b/src/errno.rs index 07c8944c..8e3a924b 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -93,7 +93,7 @@ impl Errno { desc(self) } - pub fn from_i32(err: i32) -> Errno { + pub const fn from_i32(err: i32) -> Errno { from_i32(err) } @@ -928,7 +928,7 @@ mod consts { pub const ENOTSUP: Errno = Errno::EOPNOTSUPP; } - pub fn from_i32(e: i32) -> Errno { + pub const fn from_i32(e: i32) -> Errno { use self::Errno::*; match e { @@ -1207,7 +1207,7 @@ mod consts { pub const EDEADLOCK: Errno = Errno::EDEADLK; } - pub fn from_i32(e: i32) -> Errno { + pub const fn from_i32(e: i32) -> Errno { use self::Errno::*; match e { @@ -1455,7 +1455,7 @@ mod consts { pub const EOPNOTSUPP: Errno = Errno::ENOTSUP; } - pub fn from_i32(e: i32) -> Errno { + pub const fn from_i32(e: i32) -> Errno { use self::Errno::*; match e { @@ -1692,7 +1692,7 @@ mod consts { pub const EOPNOTSUPP: Errno = Errno::ENOTSUP; } - pub fn from_i32(e: i32) -> Errno { + pub const fn from_i32(e: i32) -> Errno { use self::Errno::*; match e { @@ -1916,7 +1916,7 @@ mod consts { pub const EWOULDBLOCK: Errno = Errno::EAGAIN; } - pub fn from_i32(e: i32) -> Errno { + pub const fn from_i32(e: i32) -> Errno { use self::Errno::*; match e { @@ -2141,7 +2141,7 @@ mod consts { pub const EWOULDBLOCK: Errno = Errno::EAGAIN; } - pub fn from_i32(e: i32) -> Errno { + pub const fn from_i32(e: i32) -> Errno { use self::Errno::*; match e { @@ -2350,7 +2350,7 @@ mod consts { pub const EWOULDBLOCK: Errno = Errno::EAGAIN; } - pub fn from_i32(e: i32) -> Errno { + pub const fn from_i32(e: i32) -> Errno { use self::Errno::*; match e { @@ -2590,7 +2590,7 @@ mod consts { pub const EWOULDBLOCK: Errno = Errno::EAGAIN; } - pub fn from_i32(e: i32) -> Errno { + pub const fn from_i32(e: i32) -> Errno { use self::Errno::*; match e { diff --git a/src/sys/signal.rs b/src/sys/signal.rs index e68ebf16..95663687 100644 --- a/src/sys/signal.rs +++ b/src/sys/signal.rs @@ -133,7 +133,7 @@ impl Signal { /// This function is equivalent to `<Signal as AsRef<str>>::as_ref()`, /// with difference that returned string is `'static` /// and not bound to `self`'s lifetime. - pub fn as_str(self) -> &'static str { + pub const fn as_str(self) -> &'static str { match self { Signal::SIGHUP => "SIGHUP", Signal::SIGINT => "SIGINT", diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index 366c9afd..a964d61b 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -237,7 +237,7 @@ impl AddressFamily { /// /// Currently only supports these address families: Unix, Inet (v4 & v6), Netlink, Link/Packet /// and System. Returns None for unsupported or unknown address families. - pub fn from_i32(family: i32) -> Option<AddressFamily> { + pub const fn from_i32(family: i32) -> Option<AddressFamily> { match family { libc::AF_UNIX => Some(AddressFamily::Unix), libc::AF_INET => Some(AddressFamily::Inet), @@ -314,7 +314,7 @@ impl InetAddr { } } /// Gets the IP address associated with this socket address. - pub fn ip(&self) -> IpAddr { + pub const fn ip(&self) -> IpAddr { match *self { InetAddr::V4(ref sa) => IpAddr::V4(Ipv4Addr(sa.sin_addr)), InetAddr::V6(ref sa) => IpAddr::V6(Ipv6Addr(sa.sin6_addr)), @@ -322,7 +322,7 @@ impl InetAddr { } /// Gets the port number associated with this socket address - pub fn port(&self) -> u16 { + pub const fn port(&self) -> u16 { match *self { InetAddr::V6(ref sa) => u16::from_be(sa.sin6_port), InetAddr::V4(ref sa) => u16::from_be(sa.sin_port), @@ -393,7 +393,7 @@ impl IpAddr { } } - pub fn to_std(&self) -> net::IpAddr { + pub const fn to_std(&self) -> net::IpAddr { match *self { IpAddr::V4(ref ip) => net::IpAddr::V4(ip.to_std()), IpAddr::V6(ref ip) => net::IpAddr::V6(ip.to_std()), |