Skip to content

Commit 2ee9241

Browse files
committed
Remove feature const_option from std
1 parent 64eb9ab commit 2ee9241

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@
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
//

library/std/src/sys/windows/args.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ use crate::vec;
2121

2222
use 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+
2432
pub 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

0 commit comments

Comments
 (0)