File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 335
335
#![ feature( const_ip) ]
336
336
#![ feature( const_ipv4) ]
337
337
#![ feature( const_ipv6) ]
338
- #![ feature( const_option) ]
339
338
#![ feature( const_socketaddr) ]
340
339
#![ feature( thread_local_internals) ]
341
340
//
Original file line number Diff line number Diff line change @@ -21,6 +21,14 @@ use crate::vec;
21
21
22
22
use core:: iter;
23
23
24
+ /// This is the const equivalent to `NonZeroU16::new(n).unwrap()`
25
+ const fn non_zero_u16 ( n : u16 ) -> NonZeroU16 {
26
+ match NonZeroU16 :: new ( n) {
27
+ Some ( n) => n,
28
+ None => panic ! ( "called `unwrap` on a `None` value" ) ,
29
+ }
30
+ }
31
+
24
32
pub fn args ( ) -> Args {
25
33
// SAFETY: `GetCommandLineW` returns a pointer to a null terminated UTF-16
26
34
// string so it's safe for `WStrUnits` to use.
@@ -58,10 +66,10 @@ fn parse_lp_cmd_line<'a, F: Fn() -> OsString>(
58
66
lp_cmd_line : Option < WStrUnits < ' a > > ,
59
67
exe_name : F ,
60
68
) -> Vec < OsString > {
61
- const BACKSLASH : NonZeroU16 = NonZeroU16 :: new ( b'\\' as u16 ) . unwrap ( ) ;
62
- const QUOTE : NonZeroU16 = NonZeroU16 :: new ( b'"' as u16 ) . unwrap ( ) ;
63
- const TAB : NonZeroU16 = NonZeroU16 :: new ( b'\t' as u16 ) . unwrap ( ) ;
64
- const SPACE : NonZeroU16 = NonZeroU16 :: new ( b' ' as u16 ) . unwrap ( ) ;
69
+ const BACKSLASH : NonZeroU16 = non_zero_u16 ( b'\\' as u16 ) ;
70
+ const QUOTE : NonZeroU16 = non_zero_u16 ( b'"' as u16 ) ;
71
+ const TAB : NonZeroU16 = non_zero_u16 ( b'\t' as u16 ) ;
72
+ const SPACE : NonZeroU16 = non_zero_u16 ( b' ' as u16 ) ;
65
73
66
74
let mut ret_val = Vec :: new ( ) ;
67
75
// If the cmd line pointer is null or it points to an empty string then
You can’t perform that action at this time.
0 commit comments