@@ -18,17 +18,6 @@ use crate::sys_common::AsInner; |
|
|
18 |
18 |
use crate::sys_common::wstr::WStrUnits; |
19 |
19 |
use crate::{fmt, io, iter, vec}; |
20 |
20 |
|
21 |
|
-/// This is the const equivalent to `NonZero::new(n).unwrap()` |
22 |
|
-/// |
23 |
|
-/// FIXME(const-hack): This can be removed once `Option::unwrap` is stably const. |
24 |
|
-/// See the `const_option` feature (#67441). |
25 |
|
-const fn non_zero_u16(n: u16) -> NonZero<u16> { |
26 |
|
-match NonZero::new(n) { |
27 |
|
-Some(n) => n, |
28 |
|
-None => panic!("called `unwrap` on a `None` value"), |
29 |
|
-} |
30 |
|
-} |
31 |
|
- |
32 |
21 |
pub fn args() -> Args { |
33 |
22 |
// SAFETY: `GetCommandLineW` returns a pointer to a null terminated UTF-16 |
34 |
23 |
// string so it's safe for `WStrUnits` to use. |
@@ -66,10 +55,10 @@ fn parse_lp_cmd_line<'a, F: Fn() -> OsString>( |
|
|
66 |
55 |
lp_cmd_line: Option<WStrUnits<'a>>, |
67 |
56 |
exe_name: F, |
68 |
57 |
) -> Vec<OsString> { |
69 |
|
-const BACKSLASH: NonZero<u16> = non_zero_u16(b'\\' as u16); |
70 |
|
-const QUOTE: NonZero<u16> = non_zero_u16(b'"' as u16); |
71 |
|
-const TAB: NonZero<u16> = non_zero_u16(b'\t' as u16); |
72 |
|
-const SPACE: NonZero<u16> = non_zero_u16(b' ' as u16); |
|
58 |
+const BACKSLASH: NonZero<u16> = NonZero::new(b'\\' as u16).unwrap(); |
|
59 |
+const QUOTE: NonZero<u16> = NonZero::new(b'"' as u16).unwrap(); |
|
60 |
+const TAB: NonZero<u16> = NonZero::new(b'\t' as u16).unwrap(); |
|
61 |
+const SPACE: NonZero<u16> = NonZero::new(b' ' as u16).unwrap(); |
73 |
62 |
|
74 |
63 |
let mut ret_val = Vec::new(); |
75 |
64 |
// If the cmd line pointer is null or it points to an empty string then |