summaryrefslogtreecommitdiff
path: root/src/sys/signal.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/signal.rs')
-rw-r--r--src/sys/signal.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/sys/signal.rs b/src/sys/signal.rs
index 1224888e..b746b3d4 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -112,9 +112,14 @@ impl FromStr for Signal {
}
}
-impl AsRef<str> for Signal {
- fn as_ref(&self) -> &str {
- match *self {
+impl Signal {
+ /// Returns name of 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 {
+ match self {
Signal::SIGHUP => "SIGHUP",
Signal::SIGINT => "SIGINT",
Signal::SIGQUIT => "SIGQUIT",
@@ -157,6 +162,12 @@ impl AsRef<str> for Signal {
}
}
+impl AsRef<str> for Signal {
+ fn as_ref(&self) -> &str {
+ self.as_str()
+ }
+}
+
impl fmt::Display for Signal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(self.as_ref())