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/).
5
5
6
6
## [ Unreleased] - ReleaseDate
7
7
### Added
8
+ - Added ` Signal::as_str() ` : returns signal name as ` &'static str `
9
+ (#[ 1138] ( https://github.com/nix-rust/nix/pull/1138 ) )
8
10
9
11
- Added ` posix_fallocate ` .
10
12
([ #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 {
112
112
}
113
113
}
114
114
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 {
118
123
Signal :: SIGHUP => "SIGHUP" ,
119
124
Signal :: SIGINT => "SIGINT" ,
120
125
Signal :: SIGQUIT => "SIGQUIT" ,
@@ -157,6 +162,12 @@ impl AsRef<str> for Signal {
157
162
}
158
163
}
159
164
165
+ impl AsRef < str > for Signal {
166
+ fn as_ref ( & self ) -> & str {
167
+ self . as_str ( )
168
+ }
169
+ }
170
+
160
171
impl fmt:: Display for Signal {
161
172
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
162
173
f. write_str ( self . as_ref ( ) )
You can’t perform that action at this time.
0 commit comments