### Implement StreamingIterator for Once in Rust Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.Once Implements the core 'StreamingIterator' trait for the 'Once' struct. This enables standard forward iteration with methods like 'advance', 'get', 'next', and 'size_hint'. ```rust impl StreamingIterator for Once { type Item = T fn advance(&mut self) fn get(&self) -> Option<&Self::Item> fn size_hint(&self) -> (usize, Option) fn next(&mut self) -> Option<&Self::Item> fn is_done(&self) -> bool } ``` -------------------------------- ### Implement StreamingIterator for OnceWith Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.OnceWith Implements the core `StreamingIterator` trait for `OnceWith`. This includes methods like `next`, `advance`, `get`, `size_hint`, and `is_done`, defining the basic streaming iteration behavior. ```rust impl T> StreamingIterator for OnceWith type Item = T fn advance(&mut self) fn get(&self) -> Option<&Self::Item> fn size_hint(&self) -> (usize, Option) fn next(&mut self) -> Option<&Self::Item> fn is_done(&self) -> bool ``` -------------------------------- ### StreamingIterator Implementation for Successors Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.Successors This section details the implementation of the `StreamingIterator` trait for the `Successors` struct. It defines the `Item` type and core methods like `advance`, `get`, and `next`. It also includes adaptors like `all`, `any`, `filter`, `map`, and others common to Rust iterators. ```rust impl Option> StreamingIterator for Successors { type Item = T; fn advance(&mut self); fn get(&self) -> Option<&Self::Item>; fn size_hint(&self) -> (usize, Option); fn next(&mut self) -> Option<&Self::Item>; fn is_done(&self) -> bool; fn all(&mut self, f: F) -> bool where Self: Sized, F: FnMut(&Self::Item) -> bool; fn any(&mut self, f: F) -> bool where Self: Sized, F: FnMut(&Self::Item) -> bool; fn by_ref(&mut self) -> &mut Self where Self: Sized; fn chain(self, other: I) -> Chain where Self: Sized, I: StreamingIterator + Sized; fn cloned(self) -> Cloned where Self: Sized, Self::Item: Clone; fn copied(self) -> Copied where Self: Sized, Self::Item: Copy; fn count(self) -> usize where Self: Sized; fn filter(self, f: F) -> Filter where Self: Sized, F: FnMut(&Self::Item) -> bool; fn filter_map(self, f: F) -> FilterMap where Self: Sized, F: FnMut(&Self::Item) -> Option; fn flat_map(self, f: F) -> FlatMap where Self: Sized, J: StreamingIterator, F: FnMut(&Self::Item) -> J; fn filter_map_deref(self, f: F) -> FilterMapDeref where Self: Sized, F: FnMut(&Self::Item) -> Option; fn find(&mut self, f: F) -> Option<&Self::Item> where Self: Sized, F: FnMut(&Self::Item) -> bool; fn fuse(self) -> Fuse where Self: Sized; fn inspect(self, f: F) -> Inspect where F: FnMut(&Self::Item), Self: Sized; fn map(self, f: F) -> Map where Self: Sized, F: FnMut(&Self::Item) -> B; fn map_deref(self, f: F) -> MapDeref where Self: Sized, F: FnMut(&Self::Item) -> B; } ``` -------------------------------- ### RepeatWith StreamingIterator Implementation Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.RepeatWith Implements the `StreamingIterator` trait for `RepeatWith`. This allows `RepeatWith` to be used in streaming iterator contexts. It defines the `Item` type and provides core methods such as `advance`, `get`, `size_hint`, `next`, and `is_done`. ```rust impl T> StreamingIterator for RepeatWith { type Item = T; fn advance(&mut self) { // ... implementation details ... } fn get(&self) -> Option<&Self::Item> { // ... implementation details ... } fn size_hint(&self) -> (usize, Option) { // ... implementation details ... } fn next(&mut self) -> Option<&Self::Item> { // ... implementation details ... } fn is_done(&self) -> bool { // ... implementation details ... } } ``` -------------------------------- ### Implement StreamingIterator for FlatMap Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.FlatMap Implements the `StreamingIterator` trait for the `FlatMap` struct. This enables `FlatMap` to function as a streaming iterator, providing methods like `advance`, `is_done`, `get`, and `next`. It also includes default implementations for other `StreamingIterator` methods like `fold`, `size_hint`, `all`, `any`, `by_ref`, `chain`, `cloned`, `copied`, `count`, `filter`, `filter_map`, `flat_map`, `filter_map_deref`, `find`, `fuse`, `inspect`, `map`, `map_deref`, and `map_ref`. ```rust impl StreamingIterator for FlatMap where I: StreamingIterator, F: FnMut(&I::Item) -> J, J: StreamingIterator, Source§ #### type Item = ::Item The type of the elements being iterated over. Source§ #### fn advance(&mut self) Advances the iterator to the next element. Read more Source§ #### fn is_done(&self) -> bool Checks if `get()` will return `None`. Source§ #### fn get(&self) -> Option<&Self::Item> Returns a reference to the current element of the iterator. Source§ #### fn fold(self, init: Acc, fold: Fold) -> Acc where Self: Sized, Fold: FnMut(Acc, &Self::Item) -> Acc, Reduces the iterator’s elements to a single, final value. Source§ #### fn next(&mut self) -> Option<&Self::Item> Advances the iterator and returns the next value. Read more Source§ #### fn size_hint(&self) -> (usize, Option) Returns the bounds on the remaining length of the iterator. Source§ #### fn all(&mut self, f: F) -> bool where Self: Sized, F: FnMut(&Self::Item) -> bool, Determines if all elements of the iterator satisfy a predicate. Source§ #### fn any(&mut self, f: F) -> bool where Self: Sized, F: FnMut(&Self::Item) -> bool, Determines if any elements of the iterator satisfy a predicate. Source§ #### fn by_ref(&mut self) -> &mut Self where Self: Sized, Borrows an iterator, rather than consuming it. Read more Source§ #### fn chain(self, other: I) -> Chain where Self: Sized, I: StreamingIterator + Sized, Consumes two iterators and returns a new iterator that iterates over both in sequence. Source§ #### fn cloned(self) -> Cloned ⓘ where Self: Sized, Self::Item: Clone, Produces a normal, non-streaming, iterator by cloning the elements of this iterator. Source§ #### fn copied(self) -> Copied where Self: Sized, Self::Item: Copy, Produces a normal, non-streaming, iterator by copying the elements of this iterator. Source§ #### fn count(self) -> usize where Self: Sized, Consumes the iterator, counting the number of remaining elements and returning it. Source§ #### fn filter(self, f: F) -> Filter where Self: Sized, F: FnMut(&Self::Item) -> bool, Creates an iterator which uses a closure to determine if an element should be yielded. Source§ #### fn filter_map(self, f: F) -> FilterMap where Self: Sized, F: FnMut(&Self::Item) -> Option, Creates an iterator which both filters and maps by applying a closure to elements. Source§ #### fn flat_map(self, f: F) -> FlatMap where Self: Sized, J: StreamingIterator, F: FnMut(&Self::Item) -> J, Creates an iterator which flattens iterators obtained by applying a closure to elements. Note that the returned iterators must be streaming iterators. Source§ #### fn filter_map_deref(self, f: F) -> FilterMapDeref ⓘ where Self: Sized, F: FnMut(&Self::Item) -> Option, Creates a regular, non-streaming iterator which both filters and maps by applying a closure to elements. Source§ #### fn find(&mut self, f: F) -> Option<&Self::Item> where Self: Sized, F: FnMut(&Self::Item) -> bool, Returns the first element of the iterator that satisfies the predicate. Source§ #### fn fuse(self) -> Fuse where Self: Sized, Creates an iterator which is “well behaved” at the beginning and end of iteration. Read more Source§ #### fn inspect(self, f: F) -> Inspect where F: FnMut(&Self::Item), Self: Sized, Call a closure on each element, passing the element on. The closure is called upon calls to `advance` or `advance_back`, and exactly once per element regardless of how many times (if any) `get` is called. Source§ #### fn map(self, f: F) -> Map where Self: Sized, F: FnMut(&Self::Item) -> B, Creates an iterator which transforms elements of this iterator by passing them to a closure. Source§ #### fn map_deref(self, f: F) -> MapDeref ⓘ where Self: Sized, F: FnMut(&Self::Item) -> B, Creates a regular, non-streaming iterator which transforms elements of this iterator by passing them to a closure. Source§ #### fn map_ref(self, f: F) -> MapRef where Self: Sized, F: Fn(&Self::Item) -> &B, Creates an iterator which transforms elements of this iterator by passing them to a closure. Read more ``` -------------------------------- ### fuse Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/trait.StreamingIterator Creates an iterator which is “well behaved” at the beginning and end of iteration. The behavior of calling `get` before iteration has been started, and of continuing to call `advance` after `get` has returned `None` is normally unspecified, but this guarantees that `get` will return `None` in both cases. ```APIDOC ## fuse ### Description Creates an iterator which is “well behaved” at the beginning and end of iteration. The behavior of calling `get` before iteration has been started, and of continuing to call `advance` after `get` has returned `None` is normally unspecified, but this guarantees that `get` will return `None` in both cases. ### Method `fuse` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **Fuse** - A fused iterator. #### Response Example ```json { "fused_iterator": "" } ``` ``` -------------------------------- ### General Iterator and Borrowing Utilities Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.MapDeref Provides documentation for fundamental iterator and borrowing operations, including type identification, borrowing, and conversion utilities. ```APIDOC ## General Iterator and Borrowing Utilities ### Description This section covers utility functions for iterators and borrowing mechanisms. ### Methods #### `type_id(&self) -> TypeId` Gets the `TypeId` of `self`. ### `Borrow` Trait #### `borrow(&self) -> &T` Immutably borrows from an owned value. ### `BorrowMut` Trait #### `borrow_mut(&mut self) -> &mut T` Mutably borrows from an owned value. ### `From` Trait #### `from(t: T) -> T` Returns the argument unchanged. ### `Into` Trait #### `into(self) -> U` Calls `U::from(self)`. ### `TryFrom` Trait #### `type Error = Infallible` The type returned in the event of a conversion error. #### `try_from(value: U) -> Result>::Error>` Performs the conversion. ### `TryInto` Trait #### `type Error = >::Error` The type returned in the event of a conversion error. #### `try_into(self) -> Result>::Error>` Performs the conversion. ``` -------------------------------- ### Create a well-behaved fused iterator (Rust) Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/trait.StreamingIterator The `fuse` method wraps an iterator to ensure predictable behavior at the start and end of iteration. Specifically, `get` will always return `None` before iteration begins or after `advance` has returned `None`, preventing unexpected states. ```rust fn fuse(self) -> Fuse where Self: Sized, ``` -------------------------------- ### Iterator Adapters Documentation Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.MapDeref This section outlines common iterator adapter methods, their purpose, and usage. ```APIDOC ## Iterator Adapters This documentation describes various methods that can be called on Rust iterators to adapt their behavior. ### `for_each(self, f: F)` **Description**: Calls a closure on each element of an iterator. **Method**: `for_each` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: None **Request Example**: N/A **Response**: None ### `filter

(self, predicate: P) -> Filter` **Description**: Creates an iterator which uses a closure to determine if an element should be yielded. **Method**: `filter` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `predicate` (Closure returning bool) **Request Example**: N/A **Response**: A `Filter` iterator. ### `filter_map(self, f: F) -> FilterMap` **Description**: Creates an iterator that both filters and maps elements. **Method**: `filter_map` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `f` (Closure returning Option) **Request Example**: N/A **Response**: A `FilterMap` iterator. ### `enumerate(self) -> Enumerate` **Description**: Creates an iterator which gives the current iteration count as well as the next value. **Method**: `enumerate` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: None **Request Example**: N/A **Response**: An `Enumerate` iterator. ### `peekable(self) -> Peekable` **Description**: Creates an iterator that can peek at the next element without consuming it. **Method**: `peekable` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: None **Request Example**: N/A **Response**: A `Peekable` iterator. ### `skip_while

(self, predicate: P) -> SkipWhile` **Description**: Creates an iterator that skips elements based on a predicate. **Method**: `skip_while` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `predicate` (Closure returning bool) **Request Example**: N/A **Response**: A `SkipWhile` iterator. ### `take_while

(self, predicate: P) -> TakeWhile` **Description**: Creates an iterator that yields elements based on a predicate. **Method**: `take_while` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `predicate` (Closure returning bool) **Request Example**: N/A **Response**: A `TakeWhile` iterator. ### `map_while(self, predicate: P) -> MapWhile` **Description**: Creates an iterator that both yields elements based on a predicate and maps. **Method**: `map_while` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `predicate` (Closure returning Option) **Request Example**: N/A **Response**: A `MapWhile` iterator. ### `skip(self, n: usize) -> Skip` **Description**: Creates an iterator that skips the first `n` elements. **Method**: `skip` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `n` (usize) - The number of elements to skip. **Request Example**: N/A **Response**: A `Skip` iterator. ### `take(self, n: usize) -> Take` **Description**: Creates an iterator that yields the first `n` elements. **Method**: `take` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `n` (usize) - The maximum number of elements to yield. **Request Example**: N/A **Response**: A `Take` iterator. ### `scan(self, initial_state: St, f: F) -> Scan` **Description**: An iterator adapter which holds internal state and produces a new iterator. **Method**: `scan` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `initial_state` (Any), `f` (Closure processing state and item) **Request Example**: N/A **Response**: A `Scan` iterator. ### `flat_map(self, f: F) -> FlatMap` **Description**: Creates an iterator that works like map, but flattens nested structure. **Method**: `flat_map` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `f` (Closure returning an IntoIterator) **Request Example**: N/A **Response**: A `FlatMap` iterator. ### `flatten(self) -> Flatten` **Description**: Creates an iterator that flattens nested structure. **Method**: `flatten` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: None **Request Example**: N/A **Response**: A `Flatten` iterator. ### `map_windows(self, f: F) -> MapWindows` **Description**: Calls a function for each contiguous window of size `N` over `self` and returns an iterator over the outputs. **Method**: `map_windows` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `f` (Closure processing a slice of size N) **Request Example**: N/A **Response**: A `MapWindows` iterator. ### `fuse(self) -> Fuse` **Description**: Creates an iterator which ends after the first `None`. **Method**: `fuse` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: None **Request Example**: N/A **Response**: A `Fuse` iterator. ### `inspect(self, f: F) -> Inspect` **Description**: Does something with each element of an iterator, passing the value on. **Method**: `inspect` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `f` (Closure processing the item) **Request Example**: N/A **Response**: An `Inspect` iterator. ### `by_ref(&mut self) -> &mut Self` **Description**: Creates a “by reference” adapter for this instance of `Iterator`. **Method**: `by_ref` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: None **Request Example**: N/A **Response**: A mutable reference to the iterator. ### `collect(self) -> B` **Description**: Transforms an iterator into a collection. **Method**: `collect` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: None **Request Example**: N/A **Response**: A collection of type `B`. ### `try_collect( &mut self, ) -> <::Residual as Residual>::TryType` **Description**: Fallibly transforms an iterator into a collection, short circuiting if a failure is encountered. **Method**: `try_collect` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: None **Request Example**: N/A **Response**: A fallible collection type. ### `collect_into(self, collection: &mut E) -> &mut E` **Description**: Collects all the items from an iterator into a collection. **Method**: `collect_into` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `collection` (&mut E) - The collection to extend. **Request Example**: N/A **Response**: A mutable reference to the collection. ### `partition(self, f: F) -> (B, B)` **Description**: Consumes an iterator, creating two collections from it based on a predicate. **Method**: `partition` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `f` (Closure returning bool) **Request Example**: N/A **Response**: A tuple of two collections. ### `partition_in_place<'a, T, P>(self, predicate: P) -> usize` **Description**: Reorders the elements of this iterator _in-place_ according to a predicate. **Method**: `partition_in_place` **Endpoint**: N/A (Method on Iterator trait) **Parameters**: `predicate` (Closure returning bool) **Request Example**: N/A **Response**: The number of `true` elements found. ``` -------------------------------- ### Using StreamingIterator with while let Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/index Demonstrates the recommended way to consume a `StreamingIterator` using a `while let` loop. This pattern is crucial for correctly working with mutable references to iterators. ```rust while let Some(item) = iter.next() { // work with item } ``` -------------------------------- ### Type Information Retrieval Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.FromFn Shows how to get the `TypeId` of a type using the `type_id` method. This is part of the `Any` trait and is useful for runtime type introspection. ```rust fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. ``` -------------------------------- ### StreamingIterator Adapter Methods Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.RepeatWith Demonstrates various adapter methods available on types implementing `StreamingIterator`. These include functional methods like `all`, `any`, `filter`, `map`, and utility methods like `cloned`, `count`, and `chain`. ```rust // Example usage of some adapter methods: // let result = iterator.filter(|item| /* condition */).map(|item| /* transformation */).collect::>(); // let first_match = iterator.find(|item| /* condition */); // let count = iterator.count(); ``` -------------------------------- ### StreamingIterator::is_done Method in Rust Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/trait.StreamingIterator The `is_done` method checks if the iterator has reached its end, returning `true` if `get()` would return `None`. ```Rust fn is_done(&self) -> bool { ... } ``` -------------------------------- ### Reduce Streaming Iterator to Single Value Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.Take Reduces the elements of a streaming iterator to a single value by repeatedly applying a closure. It starts with an initial value and combines it with each element. ```rust fn fold(self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, &Self::Item) -> B, ``` -------------------------------- ### From and Into Conversions (Rust) Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.WindowsMut Standard Rust conversions. `From` allows creating a type from another, while `Into` provides the reverse conversion. `TryFrom` and `TryInto` offer fallible conversion methods, handling potential errors during the process. ```rust fn from(t: T) -> T ``` ```rust fn into(self) -> U where U: From ``` ```rust type Error = Infallible fn try_from(value: U) -> Result>::Error> where U: Into ``` ```rust type Error = >::Error fn try_into(self) -> Result>::Error> ``` -------------------------------- ### Implement Standard Iterator Adaptors for OnceWith Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.OnceWith Demonstrates the implementation of common iterator adaptor methods on `OnceWith` when it conforms to `StreamingIterator`. These include `all`, `any`, `filter`, `find`, and others, leveraging the underlying streaming capabilities. ```rust fn all(&mut self, f: F) -> bool fn any(&mut self, f: F) -> bool fn by_ref(&mut self) -> &mut Self fn chain(self, other: I) -> Chain fn cloned(self) -> Cloned fn copied(self) -> Copied fn count(self) -> usize fn filter(self, f: F) -> Filter fn filter_map(self, f: F) -> FilterMap fn flat_map(self, f: F) -> FlatMap fn filter_map_deref(self, f: F) -> FilterMapDeref fn find(&mut self, f: F) -> Option<&Self::Item> fn fuse(self) -> Fuse ``` -------------------------------- ### StreamingIterator Trait Implementation for Once Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.Once The `StreamingIterator` trait is implemented for `Once`. This is the core trait for streaming iterators, providing methods for getting the current item, advancing, and checking if the iterator is done. ```APIDOC ## Trait Implementation: StreamingIterator for Once ### Description Provides the fundamental streaming iterator functionality for the `Once` struct. ### Associated Types #### `type Item = T` * **Description**: The type of the elements being iterated over. ``` ```APIDOC ### Methods #### `advance(&mut self)` * **Description**: Advances the iterator to the next element. #### `get(&self) -> Option<&Self::Item>` * **Description**: Returns a reference to the current element of the iterator. #### `size_hint(&self) -> (usize, Option)` * **Description**: Returns the bounds on the remaining length of the iterator. For `Once`, this will typically be `(1, Some(1))` before the item is yielded and `(0, Some(0))` afterwards. #### `next(&mut self) -> Option<&Self::Item>` * **Description**: Advances the iterator and returns the next value. For `Once`, this will return `Some(&item)` on the first call and `None` subsequently. #### `is_done(&self) -> bool` * **Description**: Checks if `get()` will return `None`. Returns `true` after the single item has been yielded. #### `all(&mut self, f: F) -> bool` * **Description**: Determines if all elements of the iterator satisfy a predicate. For `Once`, this checks if the single element satisfies the predicate. * **Type Parameters**: * `F`: The type of the closure, which takes a reference to an item and returns a boolean. #### `any(&mut self, f: F) -> bool` * **Description**: Determines if any elements of the iterator satisfy a predicate. For `Once`, this checks if the single element satisfies the predicate. * **Type Parameters**: * `F`: The type of the closure, which takes a reference to an item and returns a boolean. #### `by_ref(&mut self) -> &mut Self` * **Description**: Borrows an iterator, rather than consuming it. #### `chain(self, other: I) -> Chain` * **Description**: Consumes two iterators and returns a new iterator that iterates over both in sequence. * **Type Parameters**: * `I`: The type of the other iterator, which must also be a `StreamingIterator` with the same item type. #### `cloned(self) -> Cloned` * **Description**: Produces a normal, non-streaming, iterator by cloning the elements of this iterator. Requires `Self::Item` to be `Clone`. #### `copied(self) -> Copied` * **Description**: Produces a normal, non-streaming, iterator by copying the elements of this iterator. Requires `Self::Item` to be `Copy`. #### `count(self) -> usize` * **Description**: Consumes the iterator, counting the number of remaining elements and returning it. #### `filter(self, f: F) -> Filter` * **Description**: Creates an iterator which uses a closure to determine if an element should be yielded. * **Type Parameters**: * `F`: The type of the closure, which takes a reference to an item and returns a boolean. #### `filter_map(self, f: F) -> FilterMap` * **Description**: Creates an iterator which both filters and maps by applying a closure to elements. * **Type Parameters**: * `B`: The type of the mapped elements. * `F`: The type of the closure, which takes a reference to an item and returns an `Option`. #### `flat_map(self, f: F) -> FlatMap` * **Description**: Creates an iterator which flattens iterators obtained by applying a closure to elements. Note that the returned iterators must be streaming iterators. * **Type Parameters**: * `J`: The type of the flattened iterator, which must be a `StreamingIterator`. * `F`: The type of the closure, which takes a reference to an item and returns a `J`. #### `filter_map_deref(self, f: F) -> FilterMapDeref` * **Description**: Creates a regular, non-streaming iterator which both filters and maps by applying a closure to elements. * **Type Parameters**: * `B`: The type of the mapped elements. * `F`: The type of the closure, which takes a reference to an item and returns an `Option`. #### `find(&mut self, f: F) -> Option<&Self::Item>` * **Description**: Returns the first element of the iterator that satisfies the predicate. * **Type Parameters**: * `F`: The type of the closure, which takes a reference to an item and returns a boolean. #### `fuse(self) -> Fuse` * **Description**: Creates an iterator which is “well behaved” at the beginning and end of iteration. ``` -------------------------------- ### StreamingIterator Methods Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.Inspect Common methods available on StreamingIterator, such as map, filter, skip, and take. ```APIDOC ## Iterator Transformations ### `inspect(self, f: F) -> Inspect` **Description**: Calls a closure on each element, passing the element on. The closure is called upon calls to `advance` or `advance_back`, and exactly once per element regardless of how many times (if any) `get` is called. ### `map(self, f: F) -> Map` **Description**: Creates an iterator which transforms elements of this iterator by passing them to a closure. ### `map_deref(self, f: F) -> MapDeref` **Description**: Creates a regular, non-streaming iterator which transforms elements of this iterator by passing them to a closure. ### `map_ref(self, f: F) -> MapRef` **Description**: Creates an iterator which transforms elements of this iterator by passing them to a closure. ### `nth(&mut self, n: usize) -> Option<&Self::Item>` **Description**: Consumes the first `n` elements of the iterator, returning the next one. ### `owned(self) -> Owned` **Description**: Creates a normal, non-streaming, iterator with elements produced by calling `to_owned` on the elements of this iterator. ### `position(&mut self, f: F) -> Option` **Description**: Returns the index of the first element of the iterator matching a predicate. ### `skip(self, n: usize) -> Skip` **Description**: Creates an iterator which skips the first `n` elements. ### `skip_while(self, f: F) -> SkipWhile` **Description**: Creates an iterator that skips initial elements matching a predicate. ### `take(self, n: usize) -> Take` **Description**: Creates an iterator which only returns the first `n` elements. ### `take_while(self, f: F) -> TakeWhile` **Description**: Creates an iterator which only returns initial elements matching a predicate. ### `rev(self) -> Rev` **Description**: Creates an iterator which returns elements in the opposite order. Requires `DoubleEndedStreamingIterator`. ### `for_each(self, f: F)` **Description**: Calls a closure on each element of an iterator. ``` -------------------------------- ### Blanket Implementations Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.WindowsMut Common blanket implementations available for generic types. ```APIDOC ## Blanket Implementations ### `impl Any for T` Provides the `type_id` method, allowing runtime type identification. #### `fn type_id(&self) -> TypeId` Gets the `TypeId` of `self`. ### `impl Borrow for T` Allows an owned value to be borrowed immutably. #### `fn borrow(&self) -> &T` Immutably borrows from an owned value. ### `impl BorrowMut for T` Allows an owned value to be borrowed mutably. #### `fn borrow_mut(&mut self) -> &mut T` Mutably borrows from an owned value. ### `impl From for T` Provides a way to convert a value into itself. #### `fn from(t: T) -> T` Returns the argument unchanged. ### `impl Into for T where U: From` Provides a way to convert a type `T` into another type `U` if `U` can be created from `T`. #### `fn into(self) -> U` Calls `U::from(self)`. ### `impl TryFrom for T where U: Into` Provides a fallible way to convert a type `U` into another type `T`. #### `type Error = Infallible` Represents the type of error that can occur during conversion (in this case, none). #### `fn try_from(value: U) -> Result>::Error>` Performs the conversion. ### `impl TryInto for T where U: TryFrom` Provides a fallible way to convert a type `T` into another type `U`. #### `type Error = >::Error` Represents the type of error that can occur during conversion. #### `fn try_into(self) -> Result>::Error>` Performs the conversion. ``` -------------------------------- ### Get Mutable Reference to Current Element (Rust) Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.Convert Returns a mutable reference to the current element of a `Convert` streaming iterator. This allows in-place modification of the iterator's current item. ```rust fn get_mut(&mut self) -> Option<&mut I::Item> where I: Iterator ``` -------------------------------- ### Blanket Implementations Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.RepeatWith Details blanket implementations provided for iterators, offering common functionalities. ```APIDOC ## GET /iterator/blanket_implementations ### Description Lists blanket implementations available for iterators, providing general utility functions. ### Method GET ### Endpoint /iterator/blanket_implementations ### Parameters #### Query Parameters - **trait_name** (string) - Optional - The name of the blanket trait to get details for (e.g., 'Borrow', 'CloneToUninit'). ### Response #### Success Response (200) - **trait_name** (string) - The name of the blanket trait. - **description** (string) - A brief explanation of the trait's purpose. - **methods** (array) - An array of method objects, each with 'name', 'description', 'parameters', and 'return_type'. #### Response Example ```json { "implementations": [ { "trait_name": "Borrow", "description": "Provides immutable access to the underlying data.", "methods": [ { "name": "borrow", "description": "Immutably borrows from an owned value.", "parameters": [], "return_type": "&T" } ] }, { "trait_name": "CloneToUninit", "description": "Provides functionality to clone into uninitialized memory (nightly only).", "methods": [ { "name": "clone_to_uninit", "description": "Performs copy-assignment from `self` to `dest`.", "parameters": [ { "name": "dest", "type": "*mut u8", "description": "A mutable pointer to the destination memory." } ], "return_type": "unsafe fn" } ] } ] } ``` ``` -------------------------------- ### Get Type ID - Rust Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.ConvertRef The `type_id` method, part of the `Any` trait implementation, returns the unique `TypeId` of the current type. This is useful for runtime type introspection. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### rfold Method Documentation (Rust) Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/trait.DoubleEndedStreamingIterator Details the `rfold` method, a provided method for DoubleEndedStreamingIterator. It reduces the iterator's elements into a single value starting from the back. ```rust fn rfold(self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, &Self::Item) -> B, Reduces the iterator’s elements to a single, final value, starting from the back. ``` -------------------------------- ### TryFrom and TryInto Trait Implementations Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.Repeat Details the `TryFrom` and `TryInto` trait implementations for type conversions within the streaming iterator. ```APIDOC ## TryFrom and TryInto Trait Implementations ### Description Enables fallible type conversions between different types within the streaming iterator, using `TryFrom` and `TryInto`. ### `TryFrom` Implementation - **Type `Error`**: `Infallible` - **Description**: The type returned in the event of a conversion error (infallible means no errors). - **Method `try_from`** - **Description**: Performs the conversion from type `U` into type `T`. - **Parameters**: - **value** (`U`) - The value to convert. - **Returns**: `Result>::Error>` - The result of the conversion. ### `TryInto` Implementation - **Type `Error`**: `>::Error` - **Description**: The type returned in the event of a conversion error. - **Method `try_into`** - **Description**: Performs the conversion from type `T` into type `U`. - **Returns**: `Result>::Error>` - The result of the conversion. ``` -------------------------------- ### Standard Iterator and Borrowing Methods Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.FilterMapDeref Documentation for standard iterator and borrowing methods available for types. ```APIDOC ## Standard Iterator and Borrowing Methods ### Description This section details common traits like `Borrow`, `BorrowMut`, `From`, `Into`, and `Iterator` which are fundamental for data manipulation and iteration. ### `impl IntoIterator for I where I: Iterator` * **Description**: Allows types that are already iterators to be used in contexts expecting an `IntoIterator`. * **Associated Types**: * `Item = ::Item`: The type of elements yielded by the iterator. * `IntoIter = I`: The type of the iterator itself. * **Method**: `into_iter(self) -> I` - Creates an iterator from a value. ### `impl Borrow for T` * **Description**: Enables immutable borrowing. * **Method**: `borrow(&self) -> &T` - Immutably borrows from an owned value. ### `impl BorrowMut for T` * **Description**: Enables mutable borrowing. * **Method**: `borrow_mut(&mut self) -> &mut T` - Mutably borrows from an owned value. ### `impl From for T` * **Description**: A simple conversion where a value is converted into itself. * **Method**: `from(t: T) -> T` - Returns the argument unchanged. ### `impl Into for T where U: From` * **Description**: Provides a convenient way to convert a type `T` into a type `U` if `U` implements `From`. * **Method**: `into(self) -> U` - Calls `U::from(self)`. ``` -------------------------------- ### StreamingIterator Implementation for Skip Source: https://docs.rs/streaming-iterator/latest/streaming_iterator/struct.Skip Details the implementation of the `StreamingIterator` trait for the `Skip` struct, including methods for advancing, checking if done, getting the current element, and more. ```APIDOC ## impl StreamingIterator for Skip ### Description This block details the implementation of the `StreamingIterator` trait for the `Skip` struct. ### Methods * **`item`**: `type Item = ::Item` - The type of the elements being iterated over. * **`advance`**: `fn advance(&mut self)` - Advances the iterator to the next element. * **`is_done`**: `fn is_done(&self) -> bool` - Checks if `get()` will return `None`. * **`get`**: `fn get(&self) -> Option<&I::Item>` - Returns a reference to the current element of the iterator. * **`size_hint`**: `fn size_hint(&self) -> (usize, Option)` - Returns the bounds on the remaining length of the iterator. * **`fold`**: `fn fold(self, init: Acc, fold: Fold) -> Acc` - Reduces the iterator’s elements to a single, final value. * **`next`**: `fn next(&mut self) -> Option<&Self::Item>` - Advances the iterator and returns the next value. * **`all`**: `fn all(&mut self, f: F) -> bool` - Determines if all elements of the iterator satisfy a predicate. * **`any`**: `fn any(&mut self, f: F) -> bool` - Determines if any elements of the iterator satisfy a predicate. * **`by_ref`**: `fn by_ref(&mut self) -> &mut Self` - Borrows an iterator, rather than consuming it. * **`chain`**: `fn chain(self, other: I) -> Chain` - Consumes two iterators and returns a new iterator that iterates over both in sequence. * **`cloned`**: `fn cloned(self) -> Cloned` - Produces a normal, non-streaming, iterator by cloning the elements of this iterator. * **`copied`**: `fn copied(self) -> Copied` - Produces a normal, non-streaming, iterator by copying the elements of this iterator. * **`count`**: `fn count(self) -> usize` - Consumes the iterator, counting the number of remaining elements and returning it. * **`filter`**: `fn filter(self, f: F) -> Filter` - Creates an iterator which uses a closure to determine if an element should be yielded. * **`filter_map`**: `fn filter_map(self, f: F) -> FilterMap` - Creates an iterator which both filters and maps by applying a closure to elements. * **`flat_map`**: `fn flat_map(self, f: F) -> FlatMap` - Creates an iterator which flattens iterators obtained by applying a closure to elements. * **`filter_map_deref`**: `fn filter_map_deref(self, f: F) -> FilterMapDeref` - Creates a regular, non-streaming iterator which both filters and maps by applying a closure to elements. * **`find`**: `fn find(&mut self, f: F) -> Option<&Self::Item>` - Returns the first element of the iterator that satisfies the predicate. * **`fuse`**: `fn fuse(self) -> Fuse` - Creates an iterator which is “well behaved” at the beginning and end of iteration. * **`inspect`**: `fn inspect(self, f: F) -> Inspect` - Call a closure on each element, passing the element on. * **`map`**: `fn map(self, f: F) -> Map` - Creates an iterator which transforms elements of this iterator by passing them to a closure. * **`map_deref`**: `fn map_deref(self, f: F) -> MapDeref` - Creates a regular, non-streaming iterator which transforms elements of this iterator by passing them to a closure. ```