Rollup merge of #84413 - CDirkx:args_inner_debug, r=m-ou-se
Remove `sys::args::Args::inner_debug` and use `Debug` instead This removes the method `sys::args::Args::inner_debug` on all platforms and implements `Debug` for `Args` instead. I believe this creates a more natural API for the different platforms under `sys`: export a type `Args: Debug + Iterator + ...` vs. `Args: Iterator + ...` and with a method `inner_debug`.
This commit is contained in:
commit
d1f5fc6017
@ -799,7 +799,7 @@ impl DoubleEndedIterator for Args {
|
|||||||
#[stable(feature = "std_debug", since = "1.16.0")]
|
#[stable(feature = "std_debug", since = "1.16.0")]
|
||||||
impl fmt::Debug for Args {
|
impl fmt::Debug for Args {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("Args").field("inner", &self.inner.inner.inner_debug()).finish()
|
f.debug_struct("Args").field("inner", &self.inner.inner).finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -840,7 +840,7 @@ impl DoubleEndedIterator for ArgsOs {
|
|||||||
#[stable(feature = "std_debug", since = "1.16.0")]
|
#[stable(feature = "std_debug", since = "1.16.0")]
|
||||||
impl fmt::Debug for ArgsOs {
|
impl fmt::Debug for ArgsOs {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("ArgsOs").field("inner", &self.inner.inner_debug()).finish()
|
f.debug_struct("ArgsOs").field("inner", &self.inner).finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::ffi::OsString;
|
use crate::ffi::OsString;
|
||||||
|
use crate::fmt;
|
||||||
use crate::marker::PhantomData;
|
use crate::marker::PhantomData;
|
||||||
use crate::vec;
|
use crate::vec;
|
||||||
|
|
||||||
@ -22,9 +23,9 @@ pub struct Args {
|
|||||||
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Args {
|
impl fmt::Debug for Args {
|
||||||
pub fn inner_debug(&self) -> &[OsString] {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.iter.as_slice()
|
self.iter.as_slice().fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use super::abi::usercalls::{alloc, raw::ByteBuffer};
|
use super::abi::usercalls::{alloc, raw::ByteBuffer};
|
||||||
use crate::ffi::OsString;
|
use crate::ffi::OsString;
|
||||||
|
use crate::fmt;
|
||||||
use crate::slice;
|
use crate::slice;
|
||||||
use crate::sync::atomic::{AtomicUsize, Ordering};
|
use crate::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use crate::sys::os_str::Buf;
|
use crate::sys::os_str::Buf;
|
||||||
@ -31,9 +32,9 @@ pub fn args() -> Args {
|
|||||||
|
|
||||||
pub struct Args(slice::Iter<'static, OsString>);
|
pub struct Args(slice::Iter<'static, OsString>);
|
||||||
|
|
||||||
impl Args {
|
impl fmt::Debug for Args {
|
||||||
pub fn inner_debug(&self) -> &[OsString] {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.0.as_slice()
|
self.0.as_slice().fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#![allow(dead_code)] // runtime init functions not used during testing
|
#![allow(dead_code)] // runtime init functions not used during testing
|
||||||
|
|
||||||
use crate::ffi::OsString;
|
use crate::ffi::OsString;
|
||||||
|
use crate::fmt;
|
||||||
use crate::marker::PhantomData;
|
use crate::marker::PhantomData;
|
||||||
use crate::vec;
|
use crate::vec;
|
||||||
|
|
||||||
@ -29,9 +30,9 @@ pub struct Args {
|
|||||||
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Args {
|
impl fmt::Debug for Args {
|
||||||
pub fn inner_debug(&self) -> &[OsString] {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.iter.as_slice()
|
self.iter.as_slice().fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ pub fn args() -> Args {
|
|||||||
Args {}
|
Args {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Args {
|
impl fmt::Debug for Args {
|
||||||
pub fn inner_debug(&self) -> &[OsString] {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
&[]
|
f.debug_list().finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#![deny(unsafe_op_in_unsafe_fn)]
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
use crate::ffi::{CStr, OsStr, OsString};
|
use crate::ffi::{CStr, OsStr, OsString};
|
||||||
|
use crate::fmt;
|
||||||
use crate::marker::PhantomData;
|
use crate::marker::PhantomData;
|
||||||
use crate::os::wasi::ffi::OsStrExt;
|
use crate::os::wasi::ffi::OsStrExt;
|
||||||
use crate::vec;
|
use crate::vec;
|
||||||
@ -38,9 +39,9 @@ fn maybe_args() -> Option<Vec<OsString>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Args {
|
impl fmt::Debug for Args {
|
||||||
pub fn inner_debug(&self) -> &[OsString] {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.iter.as_slice()
|
self.iter.as_slice().fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::ffi::OsString;
|
use crate::ffi::OsString;
|
||||||
|
use crate::fmt;
|
||||||
use crate::marker::PhantomData;
|
use crate::marker::PhantomData;
|
||||||
use crate::vec;
|
use crate::vec;
|
||||||
|
|
||||||
@ -17,9 +18,9 @@ pub struct Args {
|
|||||||
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Args {
|
impl fmt::Debug for Args {
|
||||||
pub fn inner_debug(&self) -> &[OsString] {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.iter.as_slice()
|
self.iter.as_slice().fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,19 +164,9 @@ pub struct Args {
|
|||||||
parsed_args_list: vec::IntoIter<OsString>,
|
parsed_args_list: vec::IntoIter<OsString>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ArgsInnerDebug<'a> {
|
impl fmt::Debug for Args {
|
||||||
args: &'a Args,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> fmt::Debug for ArgsInnerDebug<'a> {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.args.parsed_args_list.as_slice().fmt(f)
|
self.parsed_args_list.as_slice().fmt(f)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Args {
|
|
||||||
pub fn inner_debug(&self) -> ArgsInnerDebug<'_> {
|
|
||||||
ArgsInnerDebug { args: self }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user