use std::ffi::{OsStr, OsString};
use std::fmt;
use crate::sys;
use heim_common::prelude::wrap;
pub struct Command(sys::Command);
wrap!(Command, sys::Command);
impl Command {
pub fn to_os_string(&self) -> OsString {
self.as_ref().to_os_string()
}
pub fn into_os_string(self) -> OsString {
self.0.into_os_string()
}
}
impl fmt::Debug for Command {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Command")
.field(&self.to_os_string())
.finish()
}
}
#[derive(Debug)]
pub struct CommandIter<'a>(sys::CommandIter<'a>);
wrap!('a, CommandIter<'a>, sys::CommandIter<'a>);
impl<'a> IntoIterator for &'a Command {
type Item = &'a OsStr;
type IntoIter = CommandIter<'a>;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter().into()
}
}
impl<'a> Iterator for CommandIter<'a> {
type Item = &'a OsStr;
fn next(&mut self) -> Option<Self::Item> {
self.0.next()
}
}