File tree 7 files changed +19
-74
lines changed
7 files changed +19
-74
lines changed Original file line number Diff line number Diff line change @@ -108,12 +108,7 @@ impl<System: raw::KernelBase> StartupHookDefiner<System> {
108
108
let startup_hooks = & mut cfg. startup_hooks ;
109
109
let order = startup_hooks. len ( ) ;
110
110
startup_hooks. push ( CfgStartupHook {
111
- // FIXME: Work-around for `Option::expect` being not `const fn`
112
- start : if let Some ( x) = self . start {
113
- x
114
- } else {
115
- panic ! ( "`start` is not specified" )
116
- } ,
111
+ start : self . start . expect ( "`start` is not specified" ) ,
117
112
param : self . param ,
118
113
priority : self . priority ,
119
114
order,
Original file line number Diff line number Diff line change @@ -231,12 +231,7 @@ impl<System: raw::KernelInterruptLine> InterruptLineDefiner<System> {
231
231
self ,
232
232
cfg : & mut Cfg < C > ,
233
233
) -> InterruptLine < System > {
234
- // FIXME: Work-around for `Option::expect` being not `const fn`
235
- let line_num = if let Some ( line) = self . line {
236
- line
237
- } else {
238
- panic ! ( "`line` is not specified" ) ;
239
- } ;
234
+ let line_num = self . line . expect ( "`line` is not specified" ) ;
240
235
241
236
// Create a `CfgBuilderInterruptLine` for `line_num` if it doesn't exist
242
237
// yet
@@ -358,25 +353,15 @@ impl<System: raw::KernelInterruptLine> InterruptHandlerDefiner<System> {
358
353
self ,
359
354
cfg : & mut Cfg < C > ,
360
355
) -> InterruptHandler < System > {
361
- // FIXME: Work-around for `Option::expect` being not `const fn`
362
- let line_num = if let Some ( line) = self . line {
363
- line
364
- } else {
365
- panic ! ( "`line` is not specified" ) ;
366
- } ;
356
+ let line_num = self . line . expect ( "`line` is not specified" ) ;
367
357
368
358
// Add a `CfgInterruptLineInfo` at the same time
369
359
InterruptLine :: define ( ) . line ( line_num) . finish ( cfg) ;
370
360
371
361
let order = cfg. interrupt_handlers . len ( ) ;
372
362
cfg. interrupt_handlers . push ( CfgInterruptHandler {
373
363
line : line_num,
374
- // FIXME: Work-around for `Option::expect` being not `const fn`
375
- start : if let Some ( x) = self . start {
376
- x
377
- } else {
378
- panic ! ( "`start` is not specified" )
379
- } ,
364
+ start : self . start . expect ( "`start` is not specified" ) ,
380
365
param : self . param ,
381
366
priority : self . priority ,
382
367
unmanaged : self . unmanaged ,
Original file line number Diff line number Diff line change @@ -231,16 +231,8 @@ impl<System: raw::KernelSemaphore> SemaphoreDefiner<System> {
231
231
self ,
232
232
c : & mut Cfg < C > ,
233
233
) -> Semaphore < System > {
234
- let initial_value = if let Some ( x) = self . initial_value {
235
- x
236
- } else {
237
- panic ! ( "`initial` is not specified" )
238
- } ;
239
- let maximum_value = if let Some ( x) = self . maximum_value {
240
- x
241
- } else {
242
- panic ! ( "`maximum` is not specified" )
243
- } ;
234
+ let initial_value = self . initial_value . expect ( "`initial` is not specified" ) ;
235
+ let maximum_value = self . maximum_value . expect ( "`maximum` is not specified" ) ;
244
236
245
237
let id = c. raw ( ) . semaphore_define (
246
238
raw_cfg:: SemaphoreDescriptor {
Original file line number Diff line number Diff line change @@ -343,18 +343,14 @@ impl<System: raw::KernelBase> TaskDefiner<System> {
343
343
let id = cfg. raw ( ) . task_define (
344
344
raw_cfg:: TaskDescriptor {
345
345
phantom : Init :: INIT ,
346
- start : if let Some ( x) = self . start {
347
- x
348
- } else {
349
- panic ! ( "`start` (task entry point) is not specified" )
350
- } ,
346
+ start : self
347
+ . start
348
+ . expect ( "`start` (task entry point) is not specified" ) ,
351
349
param : self . param ,
352
350
active : self . active ,
353
- priority : if let Some ( x) = self . priority {
354
- x
355
- } else {
356
- panic ! ( "`priority` (task entry point) is not specified" )
357
- } ,
351
+ priority : self
352
+ . priority
353
+ . expect ( "`priority` (task entry point) is not specified" ) ,
358
354
stack_size : self . stack_size ,
359
355
} ,
360
356
( ) ,
Original file line number Diff line number Diff line change @@ -542,12 +542,9 @@ impl<System: raw::KernelTimer> TimerDefiner<System> {
542
542
let id = c. raw ( ) . timer_define (
543
543
raw_cfg:: TimerDescriptor {
544
544
phantom : Init :: INIT ,
545
- // FIXME: Work-around for `Option::expect` being not `const fn`
546
- start : if let Some ( x) = self . start {
547
- x
548
- } else {
549
- panic ! ( "`start` (timer callback function) is not specified" )
550
- } ,
545
+ start : self
546
+ . start
547
+ . expect ( "`start` (timer callback function) is not specified" ) ,
551
548
param : self . param ,
552
549
delay : self . delay ,
553
550
period : self . period ,
Original file line number Diff line number Diff line change @@ -47,25 +47,15 @@ impl Duration {
47
47
/// Pancis if `millis` overflows the representable range of `Duration`.
48
48
#[ inline]
49
49
pub const fn from_millis ( millis : i32 ) -> Self {
50
- // FIXME: `Option::expect` is not `const fn` yet
51
- Self :: from_micros ( if let Some ( x) = millis. checked_mul ( 1_000 ) {
52
- x
53
- } else {
54
- panic ! ( "duration overflow" ) ;
55
- } )
50
+ Self :: from_micros ( millis. checked_mul ( 1_000 ) . expect ( "duration overflow" ) )
56
51
}
57
52
58
53
/// Construct a new `Duration` from the specified number of seconds.
59
54
///
60
55
/// Pancis if `secs` overflows the representable range of `Duration`.
61
56
#[ inline]
62
57
pub const fn from_secs ( secs : i32 ) -> Self {
63
- // FIXME: `Option::expect` is not `const fn` yet
64
- Self :: from_micros ( if let Some ( x) = secs. checked_mul ( 1_000_000 ) {
65
- x
66
- } else {
67
- panic ! ( "duration overflow" ) ;
68
- } )
58
+ Self :: from_micros ( secs. checked_mul ( 1_000_000 ) . expect ( "duration overflow" ) )
69
59
}
70
60
71
61
/// Get the total number of whole microseconds contained by this `Duration`.
Original file line number Diff line number Diff line change @@ -51,25 +51,15 @@ impl Time {
51
51
/// Pancis if `millis` overflows the representable range of `Time`.
52
52
#[ inline]
53
53
pub const fn from_millis ( millis : u64 ) -> Self {
54
- // FIXME: `Option::expect` is not `const fn` yet
55
- Self :: from_micros ( if let Some ( x) = millis. checked_mul ( 1_000 ) {
56
- x
57
- } else {
58
- panic ! ( "duration overflow" ) ;
59
- } )
54
+ Self :: from_micros ( millis. checked_mul ( 1_000 ) . expect ( "duration overflow" ) )
60
55
}
61
56
62
57
/// Construct a new `Time` from the specified number of seconds.
63
58
///
64
59
/// Pancis if `secs` overflows the representable range of `Time`.
65
60
#[ inline]
66
61
pub const fn from_secs ( secs : u64 ) -> Self {
67
- // FIXME: `Option::expect` is not `const fn` yet
68
- Self :: from_micros ( if let Some ( x) = secs. checked_mul ( 1_000_000 ) {
69
- x
70
- } else {
71
- panic ! ( "duration overflow" ) ;
72
- } )
62
+ Self :: from_micros ( secs. checked_mul ( 1_000_000 ) . expect ( "duration overflow" ) )
73
63
}
74
64
75
65
/// Get the total number of whole microseconds contained in the time span
You can’t perform that action at this time.
0 commit comments