Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: Stabilize command_access #88436

Merged
merged 2 commits into from Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 8 additions & 12 deletions library/std/src/process.rs
Expand Up @@ -115,7 +115,7 @@ use crate::path::Path;
use crate::str;
use crate::sys::pipe::{read2, AnonPipe};
use crate::sys::process as imp;
#[unstable(feature = "command_access", issue = "44434")]
#[stable(feature = "command_access", since = "1.56.0")]
yaahc marked this conversation as resolved.
Show resolved Hide resolved
pub use crate::sys_common::process::CommandEnvs;
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};

Expand Down Expand Up @@ -943,13 +943,12 @@ impl Command {
/// # Examples
///
/// ```
/// # #![feature(command_access)]
/// use std::process::Command;
///
/// let cmd = Command::new("echo");
/// assert_eq!(cmd.get_program(), "echo");
/// ```
#[unstable(feature = "command_access", issue = "44434")]
#[stable(feature = "command_access", since = "1.56.0")]
yaahc marked this conversation as resolved.
Show resolved Hide resolved
pub fn get_program(&self) -> &OsStr {
self.inner.get_program()
}
Expand All @@ -963,7 +962,6 @@ impl Command {
/// # Examples
///
/// ```
/// # #![feature(command_access)]
/// use std::ffi::OsStr;
/// use std::process::Command;
///
Expand All @@ -972,7 +970,7 @@ impl Command {
/// let args: Vec<&OsStr> = cmd.get_args().collect();
/// assert_eq!(args, &["first", "second"]);
/// ```
#[unstable(feature = "command_access", issue = "44434")]
#[stable(feature = "command_access", since = "1.56.0")]
yaahc marked this conversation as resolved.
Show resolved Hide resolved
pub fn get_args(&self) -> CommandArgs<'_> {
CommandArgs { inner: self.inner.get_args() }
}
Expand All @@ -992,7 +990,6 @@ impl Command {
/// # Examples
///
/// ```
/// # #![feature(command_access)]
/// use std::ffi::OsStr;
/// use std::process::Command;
///
Expand All @@ -1004,7 +1001,7 @@ impl Command {
/// (OsStr::new("TZ"), None)
/// ]);
/// ```
#[unstable(feature = "command_access", issue = "44434")]
#[stable(feature = "command_access", since = "1.56.0")]
yaahc marked this conversation as resolved.
Show resolved Hide resolved
pub fn get_envs(&self) -> CommandEnvs<'_> {
self.inner.get_envs()
}
Expand All @@ -1016,7 +1013,6 @@ impl Command {
/// # Examples
///
/// ```
/// # #![feature(command_access)]
/// use std::path::Path;
/// use std::process::Command;
///
Expand All @@ -1025,7 +1021,7 @@ impl Command {
/// cmd.current_dir("/bin");
/// assert_eq!(cmd.get_current_dir(), Some(Path::new("/bin")));
/// ```
#[unstable(feature = "command_access", issue = "44434")]
#[stable(feature = "command_access", since = "1.56.0")]
yaahc marked this conversation as resolved.
Show resolved Hide resolved
pub fn get_current_dir(&self) -> Option<&Path> {
self.inner.get_current_dir()
}
Expand Down Expand Up @@ -1057,13 +1053,13 @@ impl AsInnerMut<imp::Command> for Command {
///
/// This struct is created by [`Command::get_args`]. See its documentation for
/// more.
#[unstable(feature = "command_access", issue = "44434")]
#[stable(feature = "command_access", since = "1.56.0")]
yaahc marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Debug)]
pub struct CommandArgs<'a> {
inner: imp::CommandArgs<'a>,
}

#[unstable(feature = "command_access", issue = "44434")]
#[stable(feature = "command_access", since = "1.56.0")]
yaahc marked this conversation as resolved.
Show resolved Hide resolved
impl<'a> Iterator for CommandArgs<'a> {
type Item = &'a OsStr;
fn next(&mut self) -> Option<&'a OsStr> {
Expand All @@ -1074,7 +1070,7 @@ impl<'a> Iterator for CommandArgs<'a> {
}
}

#[unstable(feature = "command_access", issue = "44434")]
#[stable(feature = "command_access", since = "1.56.0")]
yaahc marked this conversation as resolved.
Show resolved Hide resolved
impl<'a> ExactSizeIterator for CommandArgs<'a> {
fn len(&self) -> usize {
self.inner.len()
Expand Down
6 changes: 3 additions & 3 deletions library/std/src/sys_common/process.rs
Expand Up @@ -106,13 +106,13 @@ impl CommandEnv {
/// This struct is created by
/// [`Command::get_envs`][crate::process::Command::get_envs]. See its
/// documentation for more.
#[unstable(feature = "command_access", issue = "44434")]
#[stable(feature = "command_access", since = "1.56.0")]
yaahc marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Debug)]
pub struct CommandEnvs<'a> {
iter: crate::collections::btree_map::Iter<'a, EnvKey, Option<OsString>>,
}

#[unstable(feature = "command_access", issue = "44434")]
#[stable(feature = "command_access", since = "1.56.0")]
yaahc marked this conversation as resolved.
Show resolved Hide resolved
impl<'a> Iterator for CommandEnvs<'a> {
type Item = (&'a OsStr, Option<&'a OsStr>);
fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -123,7 +123,7 @@ impl<'a> Iterator for CommandEnvs<'a> {
}
}

#[unstable(feature = "command_access", issue = "44434")]
#[stable(feature = "command_access", since = "1.56.0")]
yaahc marked this conversation as resolved.
Show resolved Hide resolved
impl<'a> ExactSizeIterator for CommandEnvs<'a> {
fn len(&self) -> usize {
self.iter.len()
Expand Down