File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
66## [ Unreleased] - ReleaseDate
77### Added
8+ - Added ` Signal::as_str() ` : returns signal name as ` &'static str `
9+ (#[ 1138] ( https://github.com/nix-rust/nix/pull/1138 ) )
810
911- Added ` posix_fallocate ` .
1012 ([ #1105 ] ( https://github.com/nix-rust/nix/pull/1105 ) )
Original file line number Diff line number Diff line change @@ -112,9 +112,14 @@ impl FromStr for Signal {
112112 }
113113}
114114
115- impl AsRef < str > for Signal {
116- fn as_ref ( & self ) -> & str {
117- match * self {
115+ impl Signal {
116+ /// Returns name of signal.
117+ ///
118+ /// This function is equivalent to `<Signal as AsRef<str>>::as_ref()`,
119+ /// with difference that returned string is `'static`
120+ /// and not bound to `self`'s lifetime.
121+ pub fn as_str ( self ) -> & ' static str {
122+ match self {
118123 Signal :: SIGHUP => "SIGHUP" ,
119124 Signal :: SIGINT => "SIGINT" ,
120125 Signal :: SIGQUIT => "SIGQUIT" ,
@@ -157,6 +162,12 @@ impl AsRef<str> for Signal {
157162 }
158163}
159164
165+ impl AsRef < str > for Signal {
166+ fn as_ref ( & self ) -> & str {
167+ self . as_str ( )
168+ }
169+ }
170+
160171impl fmt:: Display for Signal {
161172 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
162173 f. write_str ( self . as_ref ( ) )
You can’t perform that action at this time.
0 commit comments