File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,21 @@ pub enum Error {
196
196
Ffi ( & ' static str ) ,
197
197
}
198
198
199
+ impl std:: fmt:: Display for Error {
200
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
201
+ match self {
202
+ Error :: Priority ( s) => write ! ( f, "unable to set priority: {}" , s) ,
203
+ Error :: PriorityNotInRange ( range) => {
204
+ write ! ( f, "priority must be within the range: {:?}" , range)
205
+ }
206
+ Error :: OS ( i) => write ! ( f, "the operating system returned error code {}" , i) ,
207
+ Error :: Ffi ( s) => write ! ( f, "FFI error: {}" , s) ,
208
+ }
209
+ }
210
+ }
211
+
212
+ impl std:: error:: Error for Error { }
213
+
199
214
/// Platform-independent thread priority value.
200
215
/// Should be in `[0; 100)` range. The higher the number is - the higher
201
216
/// the priority.
Original file line number Diff line number Diff line change 1
1
use rstest:: rstest;
2
2
3
3
#[ rstest]
4
- fn should_be_possible_to_reset_the_same_priority ( ) {
5
- let current = thread_priority:: get_current_thread_priority ( ) . unwrap ( ) ;
6
- let set_result = thread_priority:: set_current_thread_priority ( current) ;
7
- assert_eq ! ( set_result , Ok ( ( ) ) ) ;
4
+ fn should_be_possible_to_reset_the_same_priority ( ) -> Result < ( ) , Box < dyn std :: error :: Error > > {
5
+ let current = thread_priority:: get_current_thread_priority ( ) ? ;
6
+ thread_priority:: set_current_thread_priority ( current) ? ;
7
+ Ok ( ( ) )
8
8
}
9
9
10
10
#[ rstest]
You can’t perform that action at this time.
0 commit comments