diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/errno.rs | 18 | ||||
-rw-r--r-- | src/macros.rs | 2 | ||||
-rw-r--r-- | src/sys/signal.rs | 2 | ||||
-rw-r--r-- | src/sys/socket/addr.rs | 8 |
4 files changed, 15 insertions, 15 deletions
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/macros.rs b/src/macros.rs index 927e7e7c..3ccbfdd4 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -113,9 +113,9 @@ macro_rules! libc_enum { $v enum $BitFlags { $($entries)* } - #[allow(unused_doc_comment)] impl ::std::convert::TryFrom<$repr> for $BitFlags { type Error = $crate::Error; + #[allow(unused_doc_comments)] fn try_from(x: $repr) -> $crate::Result<Self> { match x { $($try_froms)* 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()), |