### Initialize AnchorHash with Resources Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.Builder.html Demonstrates initializing an AnchorHash with a predefined set of resources and then retrieving a resource based on a key. Resources can be any type, and keys must implement `std::hash::Hash`. ```rust let backend_servers = vec![ "cache1.itsallbroken.com", "cache2.itsallbroken.com", "cache3.itsallbroken.com", ]; let anchor = anchorhash::Builder::default() .with_resources(backend_servers) .build(100); let example_user_email = "dom@itsallbroken.com".to_string(); let backend = anchor.get_resource(example_user_email).unwrap(); println!("user mapped to: {}", backend); ``` -------------------------------- ### Initialize and Use AnchorHash Source: https://docs.rs/anchorhash Initializes an AnchorHash with a specified capacity and backend servers, then maps an input key to a resource. Ensure the `anchorhash` crate is added as a dependency. ```rust let anchor = anchorhash::Builder::default() .with_resources(vec![ "cache1.itsallbroken.com", "cache2.itsallbroken.com", "cache3.itsallbroken.com", ]) .build(20); let backend = anchor.get_resource("user-A").unwrap(); println!("user mapped to: {}", backend); ``` -------------------------------- ### Initialize AnchorHash with Custom Hasher Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.Builder.html Shows how to initialize an AnchorHash with a specific hash algorithm, such as the FnvBuildHasher, for potentially faster hashing with small keys. ```rust use fnv::FnvBuildHasher; let mut anchor = anchorhash::Builder::with_hasher(FnvBuildHasher::default()).build(50); ``` -------------------------------- ### take Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Creates an iterator that yields the first `n` elements. ```APIDOC ## take ### Description Creates an iterator that yields the first `n` elements, or fewer if the underlying iterator ends sooner. ### Method `take(n)` ### Parameters - **n** (usize) - The maximum number of elements to yield. ### Returns A `Take` iterator. ``` -------------------------------- ### Builder::with_resources Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.Builder.html Constructs the AnchorHash with an initial set of resources. ```APIDOC ## With Resources Construct the `AnchorHash` with an initial set of resources. ### Signature ```rust pub fn with_resources(self, resources: impl IntoIterator) -> Self ``` ``` -------------------------------- ### Builder::build Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.Builder.html Initializes the AnchorHash instance with support for up to a specified capacity of resources. ```APIDOC ## Build Initialise the `AnchorHash` instance with support for up to `capacity` number of resources. ### Signature ```rust pub fn build(self, capacity: u16) -> AnchorHash ``` ### Panics This method panics if the number of resources given to `with_resources()` exceeds `capacity`. ``` -------------------------------- ### by_ref Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Creates a reference adapter for the iterator. ```APIDOC ## by_ref ### Description Creates a “by reference” adapter for this instance of `Iterator`. ### Method `by_ref()` ### Parameters None ### Returns A mutable reference to the iterator (`&mut Self`). ``` -------------------------------- ### Builder Default Initialization Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.Builder.html Initializes an empty AnchorHash instance using the default hasher and no pre-populated resources. This is the default behavior when no specific configuration is provided. ```rust let builder: anchorhash::Builder<_, _> = Default::default(); ``` -------------------------------- ### Implement CloneToUninit for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Nightly-only experimental API for cloning data into uninitialized memory. Requires the type T to implement Clone. ```rust unsafe impl CloneToUninit for T where T: Clone { fn clone_to_uninit(&self, dest: *mut u8) { // ... } } ``` -------------------------------- ### Implement Any for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Provides runtime type information for any type T. This is a blanket implementation. ```rust impl Any for T where T: 'static + ?Sized { fn type_id(&self) -> TypeId { // ... } } ``` -------------------------------- ### Builder::default Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.Builder.html Initializes an empty AnchorHash instance using the DefaultHasher and no pre-populated resources. ```APIDOC ## Default Initialise an empty AnchorHash instance using the `DefaultHasher` and no pre-populated resources. ### Signature ```rust pub fn default() -> Self ``` ``` -------------------------------- ### Clone AnchorHash Instance Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.AnchorHash.html Demonstrates cloning an AnchorHash instance. This is possible when both the resource type (R) and the hash builder (B) implement Clone. The key type (K) does not need to implement Clone. ```rust fn clone(&self) -> Self Returns a duplicate of the value. Read more 1.0.0 · Source ``` -------------------------------- ### partition Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Consumes an iterator and creates two collections based on a predicate. ```APIDOC ## partition ### Description Consumes an iterator, creating two collections from it. ### Method `partition(f)` ### Parameters - **f** (FnMut(&Self::Item) -> bool) - A closure that determines which partition the element belongs to. ### Returns A tuple of two collections `(B, B)`. ``` -------------------------------- ### AnchorHash::get_resource Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.AnchorHash.html Consistently hash a key to a configured resource. Returns None if no resources are configured. ```APIDOC ## AnchorHash::get_resource ### Description Consistently hash `key` to a configured resource. This method will return `None` when `self` contains no resources. ### Method `get_resource(&self, key: K) -> Option<&R>` ### Parameters #### Path Parameters - **key** (K) - Required - The key to hash. ``` -------------------------------- ### product Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Iterates over the entire iterator, multiplying all the elements. ```APIDOC ## product

(self) -> P where Self: Sized, P: Product, ### Description Iterates over the entire iterator, multiplying all the elements. ### Method `product` ### Returns - `P` - The product of the elements in the iterator. ``` -------------------------------- ### AnchorHash::add_resource Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.AnchorHash.html Add a resource, allowing keys to map to it. Keys immediately begin mapping to the new resource, balancing the load. ```APIDOC ## AnchorHash::add_resource ### Description Add `resource`, allowing keys to map to it. When a new resource is added, keys immediately begin mapping to it, and the load across all the resources remains uniformly balanced. A subset of keys from each resource is mapped to the new resource ensuring minimal disruption with optimal load sharing. ### Method `add_resource(&mut self, resource: R) -> Result<(), Error>` ### Parameters #### Path Parameters - **resource** (R) - Required - The resource to add. ``` -------------------------------- ### TryFrom for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.Builder.html Provides the `try_from` method for attempting conversions. ```APIDOC #### fn try_from(value: U) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### AnchorHash::clone Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.AnchorHash.html Implement `Clone` when the resource type (`R`) and the hash builder (`B`) implement clone. The key type (`K`) does not need to implement `Clone`. ```APIDOC ## AnchorHash::clone ### Description Implement `Clone` when both the resource type (`R`) and the hash builder (`B`) implement clone. Note the key type (`K`) does NOT have to implement `Clone`. ### Method `clone(&self) -> Self` ### Returns Returns a duplicate of the value. ``` -------------------------------- ### TryInto for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.Builder.html Provides the `try_into` method for performing fallible conversions. ```APIDOC ## impl TryInto for T where U: TryFrom, ### Description This implementation provides a `try_into` method that allows for fallible conversions between types. ### Methods #### fn try_into(self) -> Result>::Error> Performs the conversion. #### type Error = >::Error The type returned in the event of a conversion error. ``` -------------------------------- ### TryFrom for ResourceIterator Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Enables fallible conversion from another type U into ResourceIterator. ```APIDOC ## TryFrom for ResourceIterator ### Description Enables fallible conversion from another type U into ResourceIterator. ### Type Alias - **Error**: The type returned in the event of a conversion error. ### Method - **try_from(value: U) -> Result>::Error>**: Performs the conversion. ``` -------------------------------- ### Iterator step_by() Method Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Creates a new iterator that yields elements from the original iterator, stepping by a specified amount. ```rust fn step_by(self, step: usize) -> StepBy where Self: Sized, ``` -------------------------------- ### TryInto for ResourceIterator Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Enables fallible conversion from ResourceIterator into another type U. ```APIDOC ## TryInto for ResourceIterator ### Description Enables fallible conversion from ResourceIterator into another type U. ### Type Alias - **Error**: The type returned in the event of a conversion error. ### Method - **try_into(self) -> Result>::Error>**: Performs the conversion. ``` -------------------------------- ### inspect Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Does something with each element of an iterator, passing the value on. ```APIDOC ## fn inspect(self, f: F) -> Inspect ### Description Does something with each element of an iterator, passing the value on. ### Parameters #### Path Parameters - `f` (F): A closure that takes a reference to an item and performs an action. ### Returns An `Inspect` iterator adapter. ``` -------------------------------- ### Iterator zip() Method Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Creates a new iterator that yields pairs of elements from this iterator and another iterator. ```rust fn zip(self, other: U) -> Zip::IntoIter> where Self: Sized, U: IntoIterator, ``` -------------------------------- ### Custom Key Type for AnchorHash Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.AnchorHash.html Demonstrates using a custom struct that derives Hash as a key for AnchorHash. This allows for compound keys without resorting to string types. ```rust use std::net::SocketAddr; // A custom key type that maps to a backend based on all values #[derive(Hash)] struct UserSession { user_id: u64, ip_addr: SocketAddr, } // Initialise a AnchorHash with the capacity for 20 backend cache servers, // and 3 active servers. let anchor = anchorhash::Builder::default() .with_resources(vec![ "cache1.itsallbroken.com", "cache2.itsallbroken.com", "cache3.itsallbroken.com", ]) .build(20); // Look up a cache backend for this user ID and requesting IP let key = UserSession { user_id: 42, ip_addr: "127.0.0.1:4242".parse().unwrap(), }; // Map the UserSession to a cache backend let backend = anchor.get_resource(&key).unwrap(); println!("user mapped to: {}", backend); ``` -------------------------------- ### Builder::with_hasher Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.Builder.html Configures the Builder to use a provided hash algorithm for hashing keys. ```APIDOC ## With Hasher Use the provided hash algorithm when hashing keys. ### Signature ```rust pub fn with_hasher(builder: B) -> Self ``` ``` -------------------------------- ### Iterator next_chunk() Method (Nightly) Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Advances the iterator and returns an array of N elements. This is a nightly-only experimental API. ```rust fn next_chunk( &mut self, ) -> Result<[Self::Item; N], IntoIter> where Self: Sized, ``` -------------------------------- ### From Implementation for ResourceMutIterator Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Allows conversion from ValuesMut to ResourceMutIterator, enabling seamless integration with other collection types. ```rust impl<'a, R> From> for ResourceMutIterator<'a, R> fn from(v: ValuesMut<'a, u16, R>) -> Self ``` -------------------------------- ### map_windows Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Calls a function for each contiguous window of size N over the iterator. ```APIDOC ## map_windows ### Description Calls the given function `f` for each contiguous window of size `N` over `self` and returns an iterator over the outputs of `f`. Like `slice::windows()`, the windows during mapping overlap as well. ### Method `map_windows(f)` ### Parameters - **f** (FnMut(&[Self::Item; N]) -> R) - A closure that takes a slice representing the window and returns a value. ### Returns A `MapWindows` iterator. ### Note This is a nightly-only experimental API. ``` -------------------------------- ### map_while Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Creates an iterator that maps elements based on a predicate and returns an Option. ```APIDOC ## map_while ### Description Creates an iterator that both yields elements based on a predicate and maps them. ### Method `map_while(predicate)` ### Parameters - **predicate** (FnMut(Self::Item) -> Option) - A closure that takes an item and returns an `Option`, where `B` is the type of the mapped element. ### Returns A `MapWhile` iterator. ``` -------------------------------- ### Iterator advance_by() Method (Nightly) Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Advances the iterator by a specified number of elements. This is a nightly-only experimental API. ```rust fn advance_by(&mut self, n: usize) -> Result<(), NonZero> ``` -------------------------------- ### AnchorHash::resources Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.AnchorHash.html Returns an iterator over references to the configured resources in an arbitrary order. ```APIDOC ## AnchorHash::resources ### Description Returns an iterator yielding references to the configured resources in an arbitrary order. ### Method `resources(&self) -> ResourceIterator<'_, R>` ``` -------------------------------- ### Build AnchorHash from Iterator Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.AnchorHash.html Constructs an AnchorHash by collecting an iterator of backends. Note that the capacity is determined by the iterator's length in this construction method. ```rust let anchor = vec!["cache1.itsallbroken.com", "cache2.itsallbroken.com"] .into_iter() .collect::>(); let backend_1 = anchor.get_resource("user-A").unwrap(); let backend_2 = anchor.get_resource("user-B").unwrap(); ``` -------------------------------- ### fold Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Folds every element into an accumulator by applying an operation. ```APIDOC ## fold ### Description Folds every element into an accumulator by applying an operation, returning the final result. ### Method `fold(init, f)` ### Parameters - **init** (B) - The initial value for the accumulator. - **f** (FnMut(B, Self::Item) -> B) - A closure that takes the accumulator and the current item, and returns the updated accumulator. ### Returns The final accumulated value of type `B`. ``` -------------------------------- ### Iterator size_hint() Method Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Provides lower and upper bounds on the remaining number of elements in the iterator. ```rust fn size_hint(&self) -> (usize, Option) ``` -------------------------------- ### any Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Tests if any element of the iterator matches a predicate. ```APIDOC ## any(&mut self, f: F) -> bool where Self: Sized, F: FnMut(Self::Item) -> bool, ### Description Tests if any element of the iterator matches a predicate. ### Method `any` ### Parameters - `f` (FnMut(Self::Item) -> bool) - A closure that takes an item and returns `true` if it matches the predicate, `false` otherwise. ### Returns - `bool` - `true` if at least one element matches the predicate, `false` otherwise. ``` -------------------------------- ### Implement TryInto for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Enables fallible conversion from type T into type U. This is the reciprocal of TryFrom. ```rust impl TryInto for T where U: TryFrom { type Error = >::Error; fn try_into(self) -> Result>::Error> { // ... } } ``` -------------------------------- ### range_map Source: https://docs.rs/anchorhash/0.2.2/anchorhash/fn.range_map.html Maps an unsigned 32-bit integer `v` into the range `[0, max)`. This operation is an efficient modulo-like operation optimized for modern 64-bit CPUs. It is based on an algorithm from Daniel Lemire's work, omitting the rejection method, which introduces a slight bias in the result. Benchmarks indicate this implementation is significantly faster than a standard modulo operation. ```APIDOC ## range_map ### Description An efficient modulo-like operation mapping `v` into the range `[0, max)` for modern 64-bit CPUs. Algorithm taken from Daniel Lemire’s `Fast Random Integer Generation in an Interval` without the rejection method, therefore accepting a bias in the result. Benchmarks (included in this crate) showed this implementation to be ~70% faster than the (already very fast) modulo implementation. ### Signature ```rust pub fn range_map(v: u32, max: u32) -> u32 ``` ### Parameters - **v** (u32) - The input value to map. - **max** (u32) - The upper bound of the range (exclusive). ### Returns - (u32) - The mapped value within the range `[0, max)`. ``` -------------------------------- ### Iterator enumerate() Method Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Creates a new iterator that yields pairs of (index, element) for each element in the original iterator. ```rust fn enumerate(self) -> Enumerate where Self: Sized, ``` -------------------------------- ### From Trait Implementation Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html ResourceIterator can be created from a `Values` iterator. ```APIDOC ### impl<'a, R> From> for ResourceIterator<'a, R> #### fn from(v: Values<'a, u16, R>) -> Self Converts to this type from the input type. ``` -------------------------------- ### fasthash Source: https://docs.rs/anchorhash/0.2.2/anchorhash/fn.fasthash.html Computes a 32-bit hash for an unsigned 32-bit integer `k` using `seed` as the initial hasher state. This is a fallback implementation for platforms that do not support the `_mm_crc32_u32` intrinsic, employing the Fowler–Noll–Vo hash function. ```APIDOC ## Function fasthash ### Description A hash function producing a 32 bit hash for `k`, using `seed` as the initial hasher state. This is a fallback implementation for platforms that do not support the `_mm_crc32_u32` intrinsic. It makes use of the Fowler–Noll–Vo hash function which is extremely quick at hashing small amounts of data. ### Signature ```rust pub fn fasthash(k: u32, seed: u32) -> u32 ``` ### Parameters #### Path Parameters - **k** (u32) - The unsigned 32-bit integer to hash. - **seed** (u32) - The initial hasher state. ### Returns - **u32** - The computed 32-bit hash value. ``` -------------------------------- ### copied Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Creates an iterator which copies all of its elements. ```APIDOC ## copied<'a, T>(self) -> Copied where T: Copy + 'a, Self: Sized + Iterator, ### Description Creates an iterator which copies all of its elements. ### Method `copied` ### Returns - `Copied` - An iterator that yields copies of the elements from the original iterator. ``` -------------------------------- ### inspect Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Performs an action for each element of an iterator without consuming it. ```APIDOC ## inspect ### Description Does something with each element of an iterator, passing the value on. ### Method `inspect(f)` ### Parameters - **f** (FnMut(&Self::Item)) - A closure that takes a reference to the current item. ### Returns An `Inspect` iterator. ``` -------------------------------- ### partial_cmp_by Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Lexicographically compares the elements of this Iterator with those of another with respect to the specified comparison function. This is a nightly-only experimental API. ```APIDOC ## fn partial_cmp_by(self, other: I, partial_cmp: F) -> Option where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, ::Item) -> Option, ### Description Lexicographically compares the elements of this `Iterator` with those of another with respect to the specified comparison function. This is a nightly-only experimental API. ### Method `partial_cmp_by` ### Parameters - `other`: An `IntoIterator` to compare against. - `partial_cmp`: A closure that takes two elements and returns an `Option`. ### Returns - `Option`: The result of the comparison, or `None` if the elements are not comparable. ``` -------------------------------- ### Iterator intersperse_with() Method (Nightly) Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Creates a new iterator that inserts elements generated by a closure between original elements. This is a nightly-only experimental API. ```rust fn intersperse_with(self, separator: G) -> IntersperseWith where Self: Sized, G: FnMut() -> Self::Item, ``` -------------------------------- ### skip Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Creates an iterator that skips the first `n` elements. ```APIDOC ## skip ### Description Creates an iterator that skips the first `n` elements. ### Method `skip(n)` ### Parameters - **n** (usize) - The number of elements to skip. ### Returns A `Skip` iterator. ``` -------------------------------- ### take_while Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Creates an iterator that yields elements based on a predicate. ```APIDOC ## take_while ### Description Creates an iterator that yields elements based on a predicate. ### Method `take_while(predicate)` ### Parameters - **predicate** (FnMut(&Self::Item) -> bool) - A closure that returns `true` if the element should be yielded. ### Returns A `TakeWhile` iterator. ``` -------------------------------- ### Iterator intersperse() Method (Nightly) Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Creates a new iterator that inserts a separator between elements. This is a nightly-only experimental API. ```rust fn intersperse(self, separator: Self::Item) -> Intersperse where Self: Sized, Self::Item: Clone, ``` -------------------------------- ### Iterator chain() Method Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Creates a new iterator that yields elements from this iterator followed by elements from another iterator. ```rust fn chain(self, other: U) -> Chain::IntoIter> where Self: Sized, U: IntoIterator, ``` -------------------------------- ### Iterator for_each() Method Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Consumes the iterator, applying a closure to each element. ```rust fn for_each(self, f: F) where Self: Sized, F: FnMut(Self::Item), ``` -------------------------------- ### Iterator map() Method Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Creates a new iterator that applies a closure to each element of the original iterator. ```rust fn map(self, f: F) -> Map where Self: Sized, F: FnMut(Self::Item) -> B, ``` -------------------------------- ### Iterator next() Method Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Advances the iterator and returns the next mutable reference to a resource, if available. ```rust fn next(&mut self) -> Option ``` -------------------------------- ### cloned Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Creates an iterator which clones all of its elements. ```APIDOC ## cloned<'a, T>(self) -> Cloned where T: Clone + 'a, Self: Sized + Iterator, ### Description Creates an iterator which `clone`s all of its elements. ### Method `cloned` ### Returns - `Cloned` - An iterator that yields clones of the elements from the original iterator. ``` -------------------------------- ### try_fold Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Applies a fallible function to each item, accumulating a result. ```APIDOC ## try_fold ### Description An iterator method that applies a function as long as it returns successfully, producing a single, final value. ### Method `try_fold(init, f)` ### Parameters - **init** (B) - The initial value for the accumulator. - **f** (FnMut(B, Self::Item) -> R) - A closure that takes the accumulator and the current item, and returns a `Try` type. ### Returns A `Try` type `R` containing the final accumulated value `B`. ``` -------------------------------- ### min Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Returns the minimum element of an iterator. ```APIDOC ## min(self) -> Option where Self: Sized, Self::Item: Ord, ### Description Returns the minimum element of an iterator. ### Method `min` ### Returns - `Option` - An `Option` containing the minimum element, or `None` if the iterator is empty. ``` -------------------------------- ### cmp_by Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Lexicographically compares the elements of this Iterator with those of another, using a specified comparison function. This is a nightly-only experimental API. ```APIDOC ## fn cmp_by(self, other: I, cmp: F) -> Ordering where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, ::Item) -> Ordering, ### Description Lexicographically compares the elements of this `Iterator` with those of another with respect to the specified comparison function. ### Experimental This is a nightly-only experimental API. ``` -------------------------------- ### unzip Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Converts an iterator of pairs into a pair of containers. ```APIDOC ## unzip(self) -> (FromA, FromB) where FromA: Default + Extend, FromB: Default + Extend, Self: Sized + Iterator, ### Description Converts an iterator of pairs into a pair of containers. ### Method `unzip` ### Returns - `(FromA, FromB)` - A tuple containing two containers, each populated with the elements from the corresponding position in the pairs. ``` -------------------------------- ### Implement Display for Error Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Provides a user-friendly string representation of the Error enum, suitable for displaying to end-users. ```rust impl Display for Error { fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result { // ... } } ``` -------------------------------- ### Implement StructuralPartialEq for Error Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Enables structural equality comparisons for the Error enum. ```rust impl StructuralPartialEq for Error {} ``` -------------------------------- ### impl TryInto for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html This block defines the TryInto trait implementation for a generic type T, allowing conversion into a generic type U, provided that U implements TryFrom. ```APIDOC ## impl TryInto for T where U: TryFrom ### Description This implementation allows a type `T` to be converted into a type `U` using the `try_into` method, provided that `U` can be created from `T` via `TryFrom`. ### Methods #### fn try_into(self) -> Result>::Error> Performs the conversion from `self` (type `T`) into `U`. Returns a `Result` which is `Ok(U)` on success or `Err(>::Error)` on failure. ``` -------------------------------- ### AnchorHash::resources_mut Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.AnchorHash.html Returns an iterator over mutable references to the configured resources in an arbitrary order. ```APIDOC ## AnchorHash::resources_mut ### Description Returns an iterator yielding mutable references to the configured resources in an arbitrary order. ### Method `resources_mut(&mut self) -> ResourceMutIterator<'_, R>` ``` -------------------------------- ### take_while Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Creates an iterator that yields elements as long as a predicate returns true. ```APIDOC ## fn take_while

(self, predicate: P) -> TakeWhile ### Description Creates an iterator that yields elements based on a predicate. ### Parameters #### Path Parameters - `predicate` (P): A closure that takes a reference to an item and returns a boolean. The iterator will yield elements as long as this closure returns `true`. ### Returns A `TakeWhile` iterator adapter. ``` -------------------------------- ### scan Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Creates an iterator that holds internal state and produces a new iterator. ```APIDOC ## scan ### Description An iterator adapter which, like `fold`, holds internal state, but unlike `fold`, produces a new iterator. ### Method `scan(initial_state, f)` ### Parameters - **initial_state** (St) - The initial state for the scan operation. - **f** (FnMut(&mut St, Self::Item) -> Option) - A closure that takes the mutable state and the current item, and returns an `Option`. ### Returns A `Scan` iterator. ``` -------------------------------- ### Implement Clone for Error Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Allows creating a duplicate of an existing Error value. This is useful for error handling and propagation. ```rust impl Clone for Error { fn clone(&self) -> Error { // ... } fn clone_from(&mut self, source: &Self) { // ... } } ``` -------------------------------- ### all Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Tests if every element of the iterator matches a predicate. ```APIDOC ## all(&mut self, f: F) -> bool where Self: Sized, F: FnMut(Self::Item) -> bool, ### Description Tests if every element of the iterator matches a predicate. ### Method `all` ### Parameters - `f` (FnMut(Self::Item) -> bool) - A closure that takes an item and returns `true` if it matches the predicate, `false` otherwise. ### Returns - `bool` - `true` if all elements match the predicate, `false` otherwise. ``` -------------------------------- ### try_reduce Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Reduces the elements to a single one by repeatedly applying a reducing operation. If the closure returns a failure, the failure is propagated back to the caller immediately. This is a nightly-only experimental API. ```APIDOC ## try_reduce( &mut self, f: impl FnMut(Self::Item, Self::Item) -> R, ) -> <::Residual as Residual::Output>>>::TryType where Self: Sized, R: Try, ::Residual: Residual>, ### Description Reduces the elements to a single one by repeatedly applying a reducing operation. If the closure returns a failure, the failure is propagated back to the caller immediately. ### Method `try_reduce` ### Parameters - `f` (impl FnMut(Self::Item, Self::Item) -> R) - A closure that takes two items and returns a `Try` type. If the closure returns a failure, it's propagated. ### Returns - `<::Residual as Residual::Output>>>::TryType` - The result of the reduction, potentially containing an error if the closure failed. ``` -------------------------------- ### min_by_key Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Returns the element that yields the minimum value from the specified function. ```APIDOC ## min_by_key(self, f: F) -> Option where B: Ord, Self: Sized, F: FnMut(&Self::Item) -> B, ### Description Returns the element that yields the minimum value from the specified function. ### Method `min_by_key` ### Parameters - `f` (FnMut(&Self::Item) -> B) - A closure that takes a reference to an item and returns a value that implements `Ord`. ### Returns - `Option` - An `Option` containing the element that produced the minimum value, or `None` if the iterator is empty. ``` -------------------------------- ### fuse Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Creates an iterator which ends after the first `None`. ```APIDOC ## fuse ### Description Creates an iterator which ends after the first `None`. ### Method `fuse()` ### Parameters None ### Returns A `Fuse` iterator. ``` -------------------------------- ### Implement TryFrom for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Enables fallible conversion from type U into type T. The conversion can fail, returning a Result. ```rust impl TryFrom for T where U: Into { type Error = Infallible; fn try_from(value: U) -> Result>::Error> { // ... } } ``` -------------------------------- ### Implement Borrow for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Allows borrowing a reference to a type T from itself. This is a fundamental trait for Rust's borrowing system. ```rust impl Borrow for T where T: ?Sized { fn borrow(&self) -> &T { // ... } } ``` -------------------------------- ### map_while Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Creates an iterator that both yields elements based on a predicate and maps them. ```APIDOC ## fn map_while(self, predicate: P) -> MapWhile ### Description Creates an iterator that both yields elements based on a predicate and maps them. ### Parameters #### Path Parameters - `predicate` (P): A closure that takes an item and returns an `Option`. If `Some(B)` is returned, the element `B` is yielded. If `None` is returned, the iteration stops. ### Returns A `MapWhile` iterator adapter. ``` -------------------------------- ### collect Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Transforms an iterator into a collection. ```APIDOC ## collect ### Description Transforms an iterator into a collection. ### Method `collect()` ### Parameters None ### Returns A collection of type `B`, where `B` implements `FromIterator`. ``` -------------------------------- ### Implement From for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html A trivial implementation of the From trait, where a value is converted into itself. This is often a base case for other conversions. ```rust impl From for T { fn from(t: T) -> T { // ... } } ``` -------------------------------- ### cycle Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Repeats an iterator endlessly. ```APIDOC ## cycle(self) -> Cycle where Self: Sized + Clone, ### Description Repeats an iterator endlessly. ### Method `cycle` ### Returns - `Cycle` - An iterator that endlessly repeats the elements of the original iterator. ``` -------------------------------- ### Implement PartialEq for Error Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Enables comparison of Error enum variants for equality. Used by the `==` operator. ```rust impl PartialEq for Error { fn eq(&self, other: &Error) -> bool { // ... } fn ne(&self, other: &Rhs) -> bool { // ... } } ``` -------------------------------- ### Partial Lexicographical Comparison with Custom Function Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Compares elements of this iterator with another using a provided partial comparison function. This is a nightly-only experimental API. ```APIDOC ## fn partial_cmp_by(self, other: I, partial_cmp: F) -> Option ### Description Lexicographically compares the elements of this `Iterator` with those of another with respect to the specified comparison function. ### Parameters - `other`: An iterator to compare against. - `partial_cmp`: A closure that takes two elements and returns an `Option`. ### Returns An `Option` indicating the partial lexicographical order, or `None` if elements are not comparable. ``` -------------------------------- ### try_find Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Applies a function to the elements of an iterator and returns the first true result or the first error. This is a nightly-only experimental API. ```APIDOC ## try_find( &mut self, f: impl FnMut(&Self::Item) -> R, ) -> <::Residual as Residual>>::TryType where Self: Sized, R: Try, ::Residual: Residual>, ### Description Applies a function to the elements of an iterator and returns the first true result or the first error. ### Method `try_find` ### Parameters - `f` (impl FnMut(&Self::Item) -> R) - A closure that takes a reference to an item and returns a `Try` type evaluating to `bool`. Returns the first `true` result or the first error encountered. ### Returns - `<::Residual as Residual>>::TryType` - The result of the search, which is either `Some(item)` if a matching element is found, or an error if the closure returns a failure. ``` -------------------------------- ### Implement Into for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Enables conversion from type T into type U, provided that U implements From. This is the reciprocal of the From trait. ```rust impl Into for T where U: From { fn into(self) -> U { // ... } } ``` -------------------------------- ### cmp Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Lexicographically compares the elements of this `Iterator` with those of another. ```APIDOC ## cmp(self, other: I) -> Ordering where I: IntoIterator, Self::Item: Ord, Self: Sized, ### Description Lexicographically compares the elements of this `Iterator` with those of another. ### Method `cmp` ### Parameters - `other` (I: IntoIterator) - Another iterator to compare against. ### Returns - `Ordering` - An `Ordering` indicating whether the first iterator is less than, equal to, or greater than the second iterator. ``` -------------------------------- ### position Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Searches for an element in an iterator, returning its index. ```APIDOC ## position

(&mut self, predicate: P) -> Option where Self: Sized, P: FnMut(Self::Item) -> bool, ### Description Searches for an element in an iterator, returning its index. ### Method `position` ### Parameters - `predicate` (FnMut(Self::Item) -> bool) - A closure that takes an item and returns `true` if it matches the desired condition. ### Returns - `Option` - An `Option` containing the index of the first element that satisfies the predicate, or `None` if no such element is found. ``` -------------------------------- ### Implement Debug for Error Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Enables the debugging representation of the Error enum, useful for logging and development. ```rust impl Debug for Error { fn fmt(&self, f: &mut Formatter<'_>) -> Result { // ... } } ``` -------------------------------- ### peekable Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Creates an iterator that allows peeking at the next element without consuming it. ```APIDOC ## peekable ### Description Creates an iterator which can use the `peek` and `peek_mut` methods to look at the next element of the iterator without consuming it. See their documentation for more information. ### Method `peekable()` ### Parameters None ### Returns A `Peekable` iterator. ``` -------------------------------- ### Iterator peekable() Method Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Creates a new iterator that allows peeking at the next element without consuming it. ```rust fn peekable(self) -> Peekable where Self: Sized, ``` -------------------------------- ### skip_while Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Creates an iterator that skips elements based on a predicate. ```APIDOC ## skip_while ### Description Creates an iterator that `skip`s elements based on a predicate. ### Method `skip_while(predicate)` ### Parameters - **predicate** (FnMut(&Self::Item) -> bool) - A closure that returns `true` if the element should be skipped. ### Returns A `SkipWhile` iterator. ``` -------------------------------- ### Implement BorrowMut for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Allows mutable borrowing of a reference to a type T from itself. Essential for in-place modifications. ```rust impl BorrowMut for T where T: ?Sized { fn borrow_mut(&mut self) -> &mut T { // ... } } ``` -------------------------------- ### Debug Trait Implementation Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html ResourceIterator implements the Debug trait for formatted output. ```APIDOC ### impl<'a, R: Debug> Debug for ResourceIterator<'a, R> #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ``` -------------------------------- ### reduce Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Reduces the elements to a single one by repeatedly applying a reducing operation. ```APIDOC ## reduce(self, f: F) -> Option where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Self::Item, ### Description Reduces the elements to a single one, by repeatedly applying a reducing operation. ### Method `reduce` ### Parameters - `f` (FnMut(Self::Item, Self::Item) -> Self::Item) - A closure that takes two items of the iterator's type and returns a single item. ### Returns - `Option` - An `Option` containing the single reduced value, or `None` if the iterator was empty. ``` -------------------------------- ### Lexicographical Comparison with Custom Function Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Compares elements of this iterator with another using a provided comparison function. This is a nightly-only experimental API. ```APIDOC ## fn cmp_by(self, other: I, cmp: F) -> Ordering ### Description Lexicographically compares the elements of this `Iterator` with those of another with respect to the specified comparison function. ### Parameters - `other`: An iterator to compare against. - `cmp`: A closure that takes two elements and returns an `Ordering`. ### Returns An `Ordering` enum indicating the lexicographical order. ``` -------------------------------- ### ResourceIterator Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html An iterator yielding resources assigned to an AnchorHash instance in an arbitrary order. ```APIDOC ## Struct ResourceIterator An iterator yielding resources assigned to an `AnchorHash` instance in an arbitrary order. ``` -------------------------------- ### Implement ToString for T Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Converts a value into a String. Requires the type T to implement the Display trait. ```rust impl ToString for T where T: Display + ?Sized { fn to_string(&self) -> String { // ... } } ``` -------------------------------- ### find Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Searches for an element of an iterator that satisfies a predicate. ```APIDOC ## find

(&mut self, predicate: P) -> Option where Self: Sized, P: FnMut(&Self::Item) -> bool, ### Description Searches for an element of an iterator that satisfies a predicate. ### Method `find` ### Parameters - `predicate` (FnMut(&Self::Item) -> bool) - A closure that takes a reference to an item and returns `true` if it matches the desired condition. ### Returns - `Option` - An `Option` containing the first element that satisfies the predicate, or `None` if no such element is found. ``` -------------------------------- ### Iterator nth() Method Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Returns the nth element of the iterator, advancing the iterator past it. ```rust fn nth(&mut self, n: usize) -> Option ``` -------------------------------- ### Clone Trait Implementation Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html ResourceIterator implements the Clone trait, allowing for duplication of the iterator. ```APIDOC ### impl<'a, R: Clone> Clone for ResourceIterator<'a, R> #### fn clone(&self) -> ResourceIterator<'a, R> Returns a duplicate of the value. #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ``` -------------------------------- ### IntoIterator for ResourceIterator Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Allows a ResourceIterator to be used in a for loop or other iteration contexts. ```APIDOC ## IntoIterator for ResourceIterator ### Description Allows a ResourceIterator to be used in a for loop or other iteration contexts. ### Type Alias - **Item**: The type of the elements being iterated over. - **IntoIter**: The type of the iterator itself. ### Method - **into_iter(self) -> I**: Creates an iterator from a value. ``` -------------------------------- ### Implement Copy for Error Source: https://docs.rs/anchorhash/0.2.2/anchorhash/enum.Error.html Indicates that the Error enum can be copied by value. This is a simple enum where copying is efficient. ```rust impl Copy for Error {} ``` -------------------------------- ### Iterator count() Method Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Consumes the iterator and returns the total number of elements it yielded. ```rust fn count(self) -> usize where Self: Sized, ``` -------------------------------- ### sum Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Sums the elements of an iterator. ```APIDOC ## sum(self) -> S where Self: Sized, S: Sum, ### Description Sums the elements of an iterator. ### Method `sum` ### Returns - `S` - The sum of the elements in the iterator. ``` -------------------------------- ### min_by Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html Returns the element that yields the minimum value with respect to the specified comparison function. ```APIDOC ## min_by(self, compare: F) -> Option where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering, ### Description Returns the element that yields the minimum value with respect to the specified comparison function. ### Method `min_by` ### Parameters - `compare` (FnMut(&Self::Item, &Self::Item) -> Ordering) - A closure that compares two elements and returns an `Ordering`. ### Returns - `Option` - An `Option` containing the minimum element according to the comparison function, or `None` if the iterator is empty. ``` -------------------------------- ### Debug Implementation for ResourceMutIterator Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Implements the Debug trait for ResourceMutIterator, allowing it to be formatted for debugging purposes. ```rust impl<'a, R: Debug> Debug for ResourceMutIterator<'a, R> fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### ExactSizeIterator Implementation for ResourceMutIterator Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceMutIterator.html Implements the ExactSizeIterator trait, providing exact length information for the iterator. ```rust impl<'a, R> ExactSizeIterator for ResourceMutIterator<'a, R> fn len(&self) -> usize fn is_empty(&self) -> bool ``` -------------------------------- ### ExactSizeIterator Trait Implementation Source: https://docs.rs/anchorhash/0.2.2/anchorhash/struct.ResourceIterator.html ResourceIterator implements ExactSizeIterator, allowing for precise length determination. ```APIDOC ### impl<'a, R> ExactSizeIterator for ResourceIterator<'a, R> #### fn len(&self) -> usize Returns the exact remaining length of the iterator. #### fn is_empty(&self) -> bool Returns `true` if the iterator is empty. (Nightly-only experimental API) ```