lending_iterator::lending_iterator::constructors

Struct FromIter

Source
#[repr(transparent)]
pub struct FromIter<I: ?Sized + Iterator>(pub I);
Expand description

Note: since this wrapper only exists to avoid coherence issues, it is guaranteed to be a #[repr(transparent)] wrapper around its inner I.

This is a property unsafe code can rely on: it can thus use transmute to construct it.

It is also a property that will be upheld within future versions (should this property ever be broken in the future, the change would then be a semver-breaking one, and the type would be renamed to avoid footguns).

Tuple Fields§

§0: I

Trait Implementations§

Source§

impl<'__, I: ?Sized + Iterator> LendingIteratorඞItem<'__> for FromIter<I>

Source§

type T = <I as Iterator>::Item

The “output” of this whole hand-rolled GAT: think of LendingIteratorඞItem<'lt>::T as of LendingIterator::Item<'lt>. Read more
Source§

impl<I: ?Sized + Iterator> LendingIterator for FromIter<I>

Source§

fn next(self: &mut FromIter<I>) -> Option<I::Item>

Query the next() Item of this Self iterator. Read more
Source§

fn filter<F>(self, should_yield: F) -> Filter<Self, F>
where Self: Sized, F: FnMut(&Item<'_, Self>) -> bool,

Source§

fn for_each(self, f: impl FnMut(Item<'_, Self>))
where Self: Sized,

Source§

fn fold<Acc>(self, acc: Acc, f: impl FnMut(Acc, Item<'_, Self>) -> Acc) -> Acc
where Self: Sized,

Source§

fn try_for_each<Err>( &mut self, f: impl FnMut(Item<'_, Self>) -> Result<(), Err>, ) -> Result<(), Err>

Source§

fn try_fold<Acc, Err>( &mut self, acc: Acc, f: impl FnMut(Acc, Item<'_, Self>) -> Result<Acc, Err>, ) -> Result<Acc, Err>

Source§

fn all(&mut self, predicate: impl FnMut(Item<'_, Self>) -> bool) -> bool
where Self: Sized,

Source§

fn any(&mut self, predicate: impl FnMut(Item<'_, Self>) -> bool) -> bool
where Self: Sized,

Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Source§

fn count(self) -> usize
where Self: Sized,

Source§

fn find<'find>( &'find mut self, predicate: impl 'find + FnMut(&Item<'_, Self>) -> bool, ) -> Option<Item<'find, Self>>
where Self: Sized,

Source§

fn fuse(self) -> Fuse<Self>
where Self: Sized,

Source§

fn nth(&mut self, n: usize) -> Option<Item<'_, Self>>

Source§

fn position<F>( &mut self, predicate: impl FnMut(Item<'_, Self>) -> bool, ) -> Option<usize>
where Self: Sized,

Source§

fn skip(self, count: usize) -> Skip<Self>
where Self: Sized,

Source§

fn take(self, count: usize) -> Take<Self>
where Self: Sized,

Source§

fn map<NewItemType: HKT, F>(self, f: F) -> Map<Self, F, NewItemType>
where for<'next> F: FnMut([&'next Self; 0], Item<'next, Self>) -> Feed<'next, NewItemType>, Self: Sized,

Source§

fn map_to_ref<R: ?Sized, F>(self, f: F) -> Map<Self, F, HKTRef<R>>
where for<'any> F: FnMut([&'any Self; 0], Item<'any, Self>) -> &'any R, Self: Sized,

Convenience method: same as .map(), but for hard-coding the HKT parameter to HKTRef<R> = HKT!(&R). Read more
Source§

fn map_to_mut<R: ?Sized, F>(self, f: F) -> Map<Self, F, HKTRefMut<R>>
where for<'any> F: FnMut([&'any Self; 0], Item<'any, Self>) -> &'any mut R, Self: Sized,

Convenience method: same as .map(), but for hard-coding the HKT parameter to HKTRefMut<R> = HKT!(&mut R). Read more
Source§

fn map_into_iter<F, NonLendingItem>(self, f: F) -> MapIntoIter<Self, F>
where F: FnMut(Item<'_, Self>) -> NonLendingItem, Self: Sized,

Convenience shorthand for .map…(…).into_iter(). Read more
Source§

fn filter_map<NewItemType: HKT, F>( self, f: F, ) -> FilterMap<Self, F, NewItemType>
where for<'next> F: FnMut([&'next Self; 0], Item<'next, Self>) -> Option<Feed<'next, NewItemType>>, Self: Sized,

Source§

fn filter_map_to_ref<R: ?Sized, F>(self, f: F) -> FilterMap<Self, F, HKTRef<R>>
where for<'any> F: FnMut([&'any Self; 0], Item<'any, Self>) -> Option<&'any R>, Self: Sized,

Convenience method: same as .filter_map(), but for hard-coding the HKT parameter to HKTRef<R> = HKT!(&R). Read more
Source§

fn filter_map_to_mut<R: ?Sized, F>( self, f: F, ) -> FilterMap<Self, F, HKTRefMut<R>>
where for<'any> F: FnMut([&'any Self; 0], Item<'any, Self>) -> Option<&'any mut R>, Self: Sized,

Convenience method: same as .filter_map(), but for hard-coding the HKT parameter to HKTRefMut<R> = HKT!(&mut R). Read more
Source§

fn filter_map_into_iter<F, NonLendingItem>( self, f: F, ) -> FilterMapIntoIter<Self, F>
where F: FnMut(Item<'_, Self>) -> Option<NonLendingItem>, Self: Sized,

Convenience shorthand for .filter_map…(…).into_iter(). Read more
Source§

fn into_iter<Item>(self) -> IntoIter<Self>
where Self: for<'any> LendingIteratorඞItem<'any, T = Item> + Sized,

Convert a Self : LendingIterator into an Iterator, provided Self::Item<'_> does not depend on '_.
Source§

fn dyn_boxed<'usability>( self, ) -> Box<dyn LendingIteratorDyn<Item = HKTItem<Self>> + 'usability>
where Self: 'usability + Sized,

Available on crate feature alloc only.
Converts this LendingIterator into a Box<dyn LendingIteratorDyn…>. Read more
Source§

fn dyn_boxed_auto<BoxedDynLendingIterator, Item: HKT>( self, ) -> BoxedDynLendingIterator
where Self: Sized + DynCoerce<BoxedDynLendingIterator, Item>,

Available on crate feature alloc only.
Converts this LendingIterator into a Box<dyn LendingIteratorDyn…>. Read more

Auto Trait Implementations§

§

impl<I> Freeze for FromIter<I>
where I: Freeze + ?Sized,

§

impl<I> RefUnwindSafe for FromIter<I>
where I: RefUnwindSafe + ?Sized,

§

impl<I> Send for FromIter<I>
where I: Send + ?Sized,

§

impl<I> Sync for FromIter<I>
where I: Sync + ?Sized,

§

impl<I> Unpin for FromIter<I>
where I: Unpin + ?Sized,

§

impl<I> UnwindSafe for FromIter<I>
where I: UnwindSafe + ?Sized,

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> 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<T> LendingIteratorDyn for T
where T: LendingIterator,

Source§

type Item = HKT<dyn for<'ඞ> WithLifetime<'ඞ, T = <T as LendingIteratorඞItem<'ඞ>>::T>>

Another approach to a GAT in stable Rust: use a classic associated type, but with a HKT bound on it, so that it can still be fed a lifetime parameter.
Source§

fn dyn_next<'n>( &'n mut self, ) -> Option<<HKT<dyn for<'ඞ> WithLifetime<'ඞ, T = <T as LendingIteratorඞItem<'ඞ>>::T>> as WithLifetime<'n>>::T>

A dyn-safe version of LendingIterator::next(), using [Self::Item]. 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.