feat: make as_os_strs easier to use

Make trailing comma optional.

Return array, rather than reference to array, to eliminate lifetime
issues.

Closes #12688
This commit is contained in:
Daniel Rainer
2026-04-29 16:44:29 +02:00
committed by Johannes Altmanninger
parent 39bd54cb49
commit 3ad45d8fb1

View File

@@ -98,14 +98,14 @@ pub fn target_os_is_cygwin() -> bool {
#[macro_export]
macro_rules! as_os_strs {
[ $( $x:expr, )* ] => {
[ $( $x:expr ),* $(,)? ] => {
{
use std::ffi::OsStr;
fn as_os_str<S: AsRef<OsStr> + ?Sized>(s: &S) -> &OsStr {
s.as_ref()
}
&[
$( as_os_str($x), )*
[
$( as_os_str($x) ),*
]
}
}