File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 335335#![ feature( const_ip) ]
336336#![ feature( const_ipv4) ]
337337#![ feature( const_ipv6) ]
338- #![ feature( const_option) ]
339338#![ feature( const_socketaddr) ]
340339#![ feature( thread_local_internals) ]
341340//
Original file line number Diff line number Diff line change @@ -21,6 +21,14 @@ use crate::vec;
2121
2222use core:: iter;
2323
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+
2432pub fn args ( ) -> Args {
2533 // SAFETY: `GetCommandLineW` returns a pointer to a null terminated UTF-16
2634 // string so it's safe for `WStrUnits` to use.
@@ -58,10 +66,10 @@ fn parse_lp_cmd_line<'a, F: Fn() -> OsString>(
5866 lp_cmd_line : Option < WStrUnits < ' a > > ,
5967 exe_name : F ,
6068) -> 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 ) ;
6573
6674 let mut ret_val = Vec :: new ( ) ;
6775 // 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