NonEmpty

Struct NonEmpty 

Source
pub struct NonEmpty<T, C> {
    pub first: T,
    pub rest: C,
}
Expand description

PositionalParameter wrapper for collection types that structurally guarantees that at least one argument is present.

Collections can be empty, so their Parameter implementations return success if no values were present on the command line. Wrapping them in this type (for instance, NonEmpty<String, Vec<String>>) ensures that at least one argument is present

Fields§

§first: T§rest: C

Implementations§

Source§

impl<T, C> NonEmpty<T, C>
where for<'a> &'a C: IntoIterator<Item = &'a T>,

Source§

impl<T, C> NonEmpty<T, C>
where for<'a> &'a mut C: IntoIterator<Item = &'a mut T>,

Trait Implementations§

Source§

impl<T: Clone, C: Clone> Clone for NonEmpty<T, C>

Source§

fn clone(&self) -> NonEmpty<T, C>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, C: Debug> Debug for NonEmpty<T, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, C> Extend<T> for NonEmpty<T, C>
where C: Extend<T>,

Source§

fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T: Hash, C: Hash> Hash for NonEmpty<T, C>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<C> Index<usize> for NonEmpty<C::Output, C>
where C: Index<usize>, C::Output: Sized,

Source§

type Output = <C as Index<usize>>::Output

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<C> IndexMut<usize> for NonEmpty<C::Output, C>
where C: IndexMut<usize>, C::Output: Sized,

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, T, C> IntoIterator for &'a NonEmpty<T, C>
where &'a C: IntoIterator<Item = &'a T>,

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = NonEmptyIter<<&'a C as IntoIterator>::IntoIter>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T, C> IntoIterator for &'a mut NonEmpty<T, C>
where &'a C: IntoIterator<Item = &'a mut T>,

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = NonEmptyIter<<&'a C as IntoIterator>::IntoIter>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<C: IntoIterator> IntoIterator for NonEmpty<C::Item, C>

Source§

type Item = <C as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = NonEmptyIter<<C as IntoIterator>::IntoIter>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: PartialEq, C: PartialEq> PartialEq for NonEmpty<T, C>

Source§

fn eq(&self, other: &NonEmpty<T, C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'arg, T, C> PositionalParameter<'arg> for NonEmpty<T, C>
where T: Value<'arg>, C: Extend<T> + Default,

Source§

fn arg<E: Error<'arg>>(argument: &'arg Arg) -> Result<Self, E>

This parameter appeared on the command line, with an argument.
Source§

fn add_arg<E: Error<'arg>>(&mut self, argument: &'arg Arg) -> Result<(), E>

This parameter appeared more than once on the command line, with an argument. Read more
Source§

fn absent() -> Result<Self, RequiredError>

This parameter was absent from the command line. Read more
Source§

impl<T: Copy, C: Copy> Copy for NonEmpty<T, C>

Source§

impl<T: Eq, C: Eq> Eq for NonEmpty<T, C>

Source§

impl<T, C> StructuralPartialEq for NonEmpty<T, C>

Auto Trait Implementations§

§

impl<T, C> Freeze for NonEmpty<T, C>
where T: Freeze, C: Freeze,

§

impl<T, C> RefUnwindSafe for NonEmpty<T, C>

§

impl<T, C> Send for NonEmpty<T, C>
where T: Send, C: Send,

§

impl<T, C> Sync for NonEmpty<T, C>
where T: Sync, C: Sync,

§

impl<T, C> Unpin for NonEmpty<T, C>
where T: Unpin, C: Unpin,

§

impl<T, C> UnwindSafe for NonEmpty<T, C>
where T: UnwindSafe, C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'arg, T> Parameter<'arg> for T
where T: PositionalParameter<'arg>,

Source§

fn absent() -> Result<T, RequiredError>

This parameter was absent from the command line. Read more
Source§

fn arg<E>(argument: &'arg Arg) -> Result<T, E>
where E: Error<'arg>,

This parameter got an argument from the command line. Read more
Source§

fn present<E>(argument: impl ArgAccess<'arg>) -> Result<T, E>
where E: Error<'arg>,

This parameter appeared on the command line. Read more
Source§

fn add_arg<E>(&mut self, argument: &'arg Arg) -> Result<(), E>
where E: Error<'arg>,

This parameter appeared an additional time on the command line, with an argument. Read more
Source§

fn add_present<E>(&mut self, argument: impl ArgAccess<'arg>) -> Result<(), E>
where E: Error<'arg>,

This parameter appeared more than once on the command line. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.