pub struct OneOrMore<T> {
head: T,
tail: Vec<T>,
}
Expand description
A container for at least one item. As a convenience, we don’t
implement methods that reduce the length of the container (so
that, for example, we don’t have to implement a fallible
equivalent of pop()
). However, the container is mutable in the
sense that the items stored in it can be mutated.
Fields§
§head: T
§tail: Vec<T>
Implementations§
Source§impl<T> OneOrMore<T>
impl<T> OneOrMore<T>
Sourcepub fn with_tail(head: T, tail: Vec<T>) -> OneOrMore<T>
pub fn with_tail(head: T, tail: Vec<T>) -> OneOrMore<T>
Create an instance of OneOrMore<T>
from a single T
value
and zero or more additional T
values.
Sourcepub fn iter(&self) -> OneOrMoreIter<'_, T> ⓘ
pub fn iter(&self) -> OneOrMoreIter<'_, T> ⓘ
Return an iterator for the collection.
Sourcepub fn into_iter(self) -> OneOrMoreIntoIter<T> ⓘ
pub fn into_iter(self) -> OneOrMoreIntoIter<T> ⓘ
Convert the collection into an iterator over the items of the collection.
Sourcepub fn iter_mut(&mut self) -> OneOrMoreIterMut<'_, T> ⓘ
pub fn iter_mut(&mut self) -> OneOrMoreIterMut<'_, T> ⓘ
Return a iterator for the collection which allows the items within it (but not the number of items) to be modified.
Sourcepub fn try_from_iter<I: Iterator<Item = T>>(it: I) -> Result<Self, NoItems>
pub fn try_from_iter<I: Iterator<Item = T>>(it: I) -> Result<Self, NoItems>
Build an instance of OneOrMore<T>
from a sequence of items,
or fail (because there were no items).
Sourcepub fn extend<I: Iterator<Item = T>>(&mut self, items: I)
pub fn extend<I: Iterator<Item = T>>(&mut self, items: I)
Append a (possibly empty) sequence of items.
Sourcepub fn try_from_vec(value: Vec<T>) -> Result<OneOrMore<T>, NoItems>
pub fn try_from_vec(value: Vec<T>) -> Result<OneOrMore<T>, NoItems>
Attempt to convert an instance of OneOrMore<T>
from a
Vec<T>
. This fails if the vector is empty.
Sourcepub fn as_parts(&self) -> (&T, &Vec<T>)
pub fn as_parts(&self) -> (&T, &Vec<T>)
Return a reference the head of the collection (i.e. the first item) and a reference to the remaining items.
Trait Implementations§
Source§impl From<OneOrMore<CommaDelimitedFragment>> for UntaggedProgramInstruction
impl From<OneOrMore<CommaDelimitedFragment>> for UntaggedProgramInstruction
Source§fn from(fragments: OneOrMore<CommaDelimitedFragment>) -> Self
fn from(fragments: OneOrMore<CommaDelimitedFragment>) -> Self
impl<T: Eq> Eq for OneOrMore<T>
impl<T> StructuralPartialEq for OneOrMore<T>
Auto Trait Implementations§
impl<T> Freeze for OneOrMore<T>where
T: Freeze,
impl<T> RefUnwindSafe for OneOrMore<T>where
T: RefUnwindSafe,
impl<T> Send for OneOrMore<T>where
T: Send,
impl<T> Sync for OneOrMore<T>where
T: Sync,
impl<T> Unpin for OneOrMore<T>where
T: Unpin,
impl<T> UnwindSafe for OneOrMore<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef
].