Struct clap_stdin::MaybeStdin
source · pub struct MaybeStdin<T> {
pub source: Source,
/* private fields */
}
Expand description
Wrapper struct to parse arg values from stdin
MaybeStdin
can wrap any type that matches the trait bounds for Arg
: FromStr
and Clone
use std::path::PathBuf;
use clap::Parser;
use clap_stdin::MaybeStdin;
#[derive(Debug, Parser)]
struct Args {
path: MaybeStdin<PathBuf>,
}
if let Ok(args) = Args::try_parse() {
println!("path={}", args.path.display());
}
$ pwd | ./example -
/current/working/dir
Fields§
§source: Source
Source of the contents
Implementations§
source§impl<T> MaybeStdin<T>
impl<T> MaybeStdin<T>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Extract the inner value from the wrapper
Trait Implementations§
source§impl<T: Clone> Clone for MaybeStdin<T>
impl<T: Clone> Clone for MaybeStdin<T>
source§fn clone(&self) -> MaybeStdin<T>
fn clone(&self) -> MaybeStdin<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T> Debug for MaybeStdin<T>where
T: Debug,
impl<T> Debug for MaybeStdin<T>where
T: Debug,
source§impl<T> Deref for MaybeStdin<T>
impl<T> Deref for MaybeStdin<T>
source§impl<T> DerefMut for MaybeStdin<T>
impl<T> DerefMut for MaybeStdin<T>
source§impl<T> Display for MaybeStdin<T>where
T: Display,
impl<T> Display for MaybeStdin<T>where
T: Display,
Auto Trait Implementations§
impl<T> RefUnwindSafe for MaybeStdin<T>where
T: RefUnwindSafe,
impl<T> Send for MaybeStdin<T>where
T: Send,
impl<T> Sync for MaybeStdin<T>where
T: Sync,
impl<T> Unpin for MaybeStdin<T>where
T: Unpin,
impl<T> UnwindSafe for MaybeStdin<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more