Transforms the [`Realms `] into a [`Realms `] by applying a function to each value. Maps each value in this container to a new value using the provided closure. Returns a new [`Realms `] containing the mapped values for each universe. # Examples ``` use hashql_core::module::universe::{Realms, Universe}; let mut realms = Realms:: ::new(); realms.of_mut(Universe::Type) = 2; realms.of
(&self, mut closure: impl FnMut(&T) -> U)
| 181 | /// assert_eq!(*doubled.of(Universe::Value), 6); |
| 182 | /// ``` |
| 183 | pub fn map<U>(&self, mut closure: impl FnMut(&T) -> U) -> Realms<U> |
| 184 | where |
| 185 | U: Default, |
| 186 | { |
| 187 | let mut result = Realms::<U>::new(); |
| 188 | |
| 189 | for (universe, value) in self.realms() { |
| 190 | *result.of_mut(universe) = closure(value); |
| 191 | } |
| 192 | |
| 193 | result |
| 194 | } |
| 195 | |
| 196 | /// Tests if any value in this container satisfies the predicate. |
| 197 | /// |