| 1 | //! Free functions that create iterator adaptors or call iterator methods. |
| 2 | //! |
| 3 | //! The benefit of free functions is that they accept any [`IntoIterator`] as |
| 4 | //! argument, so the resulting code may be easier to read. |
| 5 | |
| 6 | #[cfg(feature = "use_alloc")] |
| 7 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#; |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::{selfrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/, Ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/zip/Zip#}; |
| 9 | #[cfg(feature = "use_alloc")] |
| 10 | type VecIntoIterrust-analyzer cargo itertools 0.14.0 free/VecIntoIter#<T> = allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::IntoIterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/IntoIter#<T>; |
| 11 | |
| 12 | #[cfg(feature = "use_alloc")] |
| 13 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#; |
| 14 | |
| 15 | use craterust-analyzer cargo itertools 0.14.0 crate/::intersperserust-analyzer cargo itertools 0.14.0 intersperse/::{Intersperserust-analyzer cargo itertools 0.14.0 intersperse/Intersperse#, IntersperseWithrust-analyzer cargo itertools 0.14.0 intersperse/IntersperseWith#}; |
| 16 | use craterust-analyzer cargo itertools 0.14.0 crate/::Itertoolsrust-analyzer cargo itertools 0.14.0 Itertools#; |
| 17 | |
| 18 | pub use craterust-analyzer cargo itertools 0.14.0 crate/::adaptorsrust-analyzer cargo itertools 0.14.0 adaptors/::{interleaverust-analyzer cargo itertools 0.14.0 adaptors/interleave()., put_backrust-analyzer cargo itertools 0.14.0 adaptors/put_back().}; |
| 19 | #[cfg(feature = "use_alloc")] |
| 20 | pub use craterust-analyzer cargo itertools 0.14.0 crate/::kmerge_implrust-analyzer cargo itertools 0.14.0 kmerge_impl/::kmergerust-analyzer cargo itertools 0.14.0 kmerge_impl/kmerge().; |
| 21 | pub use craterust-analyzer cargo itertools 0.14.0 crate/::merge_joinrust-analyzer cargo itertools 0.14.0 merge_join/::{mergerust-analyzer cargo itertools 0.14.0 merge_join/merge()., merge_join_byrust-analyzer cargo itertools 0.14.0 merge_join/merge_join_by().}; |
| 22 | #[cfg(feature = "use_alloc")] |
| 23 | pub use craterust-analyzer cargo itertools 0.14.0 crate/::multipeek_implrust-analyzer cargo itertools 0.14.0 multipeek_impl/::multipeekrust-analyzer cargo itertools 0.14.0 multipeek_impl/multipeek().; |
| 24 | #[cfg(feature = "use_alloc")] |
| 25 | pub use craterust-analyzer cargo itertools 0.14.0 crate/::peek_nthrust-analyzer cargo itertools 0.14.0 peek_nth/::peek_nthrust-analyzer cargo itertools 0.14.0 peek_nth/peek_nth().; |
| 26 | #[cfg(feature = "use_alloc")] |
| 27 | pub use craterust-analyzer cargo itertools 0.14.0 crate/::put_back_n_implrust-analyzer cargo itertools 0.14.0 put_back_n_impl/::put_back_nrust-analyzer cargo itertools 0.14.0 put_back_n_impl/put_back_n().; |
| 28 | #[cfg(feature = "use_alloc")] |
| 29 | pub use craterust-analyzer cargo itertools 0.14.0 crate/::rciter_implrust-analyzer cargo itertools 0.14.0 rciter_impl/::rciterrust-analyzer cargo itertools 0.14.0 rciter_impl/rciter().; |
| 30 | pub use craterust-analyzer cargo itertools 0.14.0 crate/::zip_eq_implrust-analyzer cargo itertools 0.14.0 zip_eq_impl/::zip_eqrust-analyzer cargo itertools 0.14.0 zip_eq_impl/zip_eq().; |
| 31 | |
| 32 | /// Iterate `iterable` with a particular value inserted between each element. |
| 33 | /// |
| 34 | /// [`IntoIterator`] enabled version of [`Iterator::intersperse`]. |
| 35 | /// |
| 36 | /// ``` |
| 37 | /// use itertools::intersperse; |
| 38 | /// |
| 39 | /// itertools::assert_equal(intersperse(0..3, 8), vec![0, 8, 1, 8, 2]); |
| 40 | /// ``` |
| 41 | pub fn intersperserust-analyzer cargo itertools 0.14.0 free/intersperse().<I>(iterable: I, element: I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#) -> Intersperserust-analyzer cargo itertools 0.14.0 intersperse/Intersperse#<I::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#> |
| 42 | where |
| 43 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 44 | <I as IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#>::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 45 | { |
| 46 | Itertoolsrust-analyzer cargo itertools 0.14.0 Itertools#::intersperserust-analyzer cargo itertools 0.14.0 Itertools#intersperse().(iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().(), element) |
| 47 | } |
| 48 | |
| 49 | /// Iterate `iterable` with a particular value created by a function inserted |
| 50 | /// between each element. |
| 51 | /// |
| 52 | /// [`IntoIterator`] enabled version of [`Iterator::intersperse_with`]. |
| 53 | /// |
| 54 | /// ``` |
| 55 | /// use itertools::intersperse_with; |
| 56 | /// |
| 57 | /// let mut i = 10; |
| 58 | /// itertools::assert_equal(intersperse_with(0..3, || { i -= 1; i }), vec![0, 9, 1, 8, 2]); |
| 59 | /// assert_eq!(i, 8); |
| 60 | /// ``` |
| 61 | pub fn intersperse_withrust-analyzer cargo itertools 0.14.0 free/intersperse_with().<I, F>(iterable: I, element: F) -> IntersperseWithrust-analyzer cargo itertools 0.14.0 intersperse/IntersperseWith#<I::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#, F> |
| 62 | where |
| 63 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 64 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#() -> I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#, |
| 65 | { |
| 66 | Itertoolsrust-analyzer cargo itertools 0.14.0 Itertools#::intersperse_withrust-analyzer cargo itertools 0.14.0 Itertools#intersperse_with().(iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().(), element) |
| 67 | } |
| 68 | |
| 69 | /// Iterate `iterable` with a running index. |
| 70 | /// |
| 71 | /// [`IntoIterator`] enabled version of [`Iterator::enumerate`]. |
| 72 | /// |
| 73 | /// ``` |
| 74 | /// use itertools::enumerate; |
| 75 | /// |
| 76 | /// for (i, elt) in enumerate(&[1, 2, 3]) { |
| 77 | /// /* loop body */ |
| 78 | /// # let _ = (i, elt); |
| 79 | /// } |
| 80 | /// ``` |
| 81 | pub fn enumeraterust-analyzer cargo itertools 0.14.0 free/enumerate().<I>(iterable: I) -> iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::Enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/enumerate/Enumerate#<I::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#> |
| 82 | where |
| 83 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 84 | { |
| 85 | iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() |
| 86 | } |
| 87 | |
| 88 | /// Iterate `iterable` in reverse. |
| 89 | /// |
| 90 | /// [`IntoIterator`] enabled version of [`Iterator::rev`]. |
| 91 | /// |
| 92 | /// ``` |
| 93 | /// use itertools::rev; |
| 94 | /// |
| 95 | /// for elt in rev(&[1, 2, 3]) { |
| 96 | /// /* loop body */ |
| 97 | /// # let _ = elt; |
| 98 | /// } |
| 99 | /// ``` |
| 100 | pub fn revrust-analyzer cargo itertools 0.14.0 free/rev().<I>(iterable: I) -> iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::Revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/rev/Rev#<I::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#> |
| 101 | where |
| 102 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 103 | I::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#: DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator#, |
| 104 | { |
| 105 | iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() |
| 106 | } |
| 107 | |
| 108 | /// Converts the arguments to iterators and zips them. |
| 109 | /// |
| 110 | /// [`IntoIterator`] enabled version of [`Iterator::zip`]. |
| 111 | /// |
| 112 | /// ## Example |
| 113 | /// |
| 114 | /// ``` |
| 115 | /// use itertools::zip; |
| 116 | /// |
| 117 | /// let mut result: Vec<(i32, char)> = Vec::new(); |
| 118 | /// |
| 119 | /// for (a, b) in zip(&[1, 2, 3, 4, 5], &['a', 'b', 'c']) { |
| 120 | /// result.push((*a, *b)); |
| 121 | /// } |
| 122 | /// assert_eq!(result, vec![(1, 'a'),(2, 'b'),(3, 'c')]); |
| 123 | /// ``` |
| 124 | #[deprecated( |
| 125 | note = "Use [std::iter::zip](https://doc.rust-lang.org/std/iter/fn.zip.html) instead", |
| 126 | since = "0.10.4" |
| 127 | )] |
| 128 | pub fn ziprust-analyzer cargo itertools 0.14.0 free/zip().<I, J>(i: I, j: J) -> Ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/zip/Zip#<I::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#, J::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#> |
| 129 | where |
| 130 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 131 | J: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 132 | { |
| 133 | i.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(j) |
| 134 | } |
| 135 | |
| 136 | /// Takes two iterables and creates a new iterator over both in sequence. |
| 137 | /// |
| 138 | /// [`IntoIterator`] enabled version of [`Iterator::chain`]. |
| 139 | /// |
| 140 | /// ## Example |
| 141 | /// ``` |
| 142 | /// use itertools::chain; |
| 143 | /// |
| 144 | /// let mut result:Vec<i32> = Vec::new(); |
| 145 | /// |
| 146 | /// for element in chain(&[1, 2, 3], &[4]) { |
| 147 | /// result.push(*element); |
| 148 | /// } |
| 149 | /// assert_eq!(result, vec![1, 2, 3, 4]); |
| 150 | /// ``` |
| 151 | pub fn chainrust-analyzer cargo itertools 0.14.0 free/chain().<I, J>( |
| 152 | i: I, |
| 153 | j: J, |
| 154 | ) -> iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::Chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/chain/Chain#<<I as IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#>::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#, <J as IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#>::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#> |
| 155 | where |
| 156 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 157 | J: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#>, |
| 158 | { |
| 159 | i.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(j) |
| 160 | } |
| 161 | |
| 162 | /// Create an iterator that clones each element from `&T` to `T`. |
| 163 | /// |
| 164 | /// [`IntoIterator`] enabled version of [`Iterator::cloned`]. |
| 165 | /// |
| 166 | /// ``` |
| 167 | /// use itertools::cloned; |
| 168 | /// |
| 169 | /// assert_eq!(cloned(b"abc").next(), Some(b'a')); |
| 170 | /// ``` |
| 171 | pub fn clonedrust-analyzer cargo itertools 0.14.0 free/cloned().<'a, I, T>(iterable: I) -> iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::Clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/Cloned#<I::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#> |
| 172 | where |
| 173 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = &'a T>, |
| 174 | T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + 'a, |
| 175 | { |
| 176 | iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().() |
| 177 | } |
| 178 | |
| 179 | /// Perform a fold operation over the iterable. |
| 180 | /// |
| 181 | /// [`IntoIterator`] enabled version of [`Iterator::fold`]. |
| 182 | /// |
| 183 | /// ``` |
| 184 | /// use itertools::fold; |
| 185 | /// |
| 186 | /// assert_eq!(fold(&[1., 2., 3.], 0., |a, &b| f32::max(a, b)), 3.); |
| 187 | /// ``` |
| 188 | pub fn foldrust-analyzer cargo itertools 0.14.0 free/fold().<I, B, F>(iterable: I, init: B, f: F) -> B |
| 189 | where |
| 190 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 191 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(B, I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#) -> B, |
| 192 | { |
| 193 | iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#fold().(init, f) |
| 194 | } |
| 195 | |
| 196 | /// Test whether the predicate holds for all elements in the iterable. |
| 197 | /// |
| 198 | /// [`IntoIterator`] enabled version of [`Iterator::all`]. |
| 199 | /// |
| 200 | /// ``` |
| 201 | /// use itertools::all; |
| 202 | /// |
| 203 | /// assert!(all(&[1, 2, 3], |elt| *elt > 0)); |
| 204 | /// ``` |
| 205 | pub fn allrust-analyzer cargo itertools 0.14.0 free/all().<I, F>(iterable: I, f: F) -> bool |
| 206 | where |
| 207 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 208 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#) -> bool, |
| 209 | { |
| 210 | iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(f) |
| 211 | } |
| 212 | |
| 213 | /// Test whether the predicate holds for any elements in the iterable. |
| 214 | /// |
| 215 | /// [`IntoIterator`] enabled version of [`Iterator::any`]. |
| 216 | /// |
| 217 | /// ``` |
| 218 | /// use itertools::any; |
| 219 | /// |
| 220 | /// assert!(any(&[0, -1, 2], |elt| *elt > 0)); |
| 221 | /// ``` |
| 222 | pub fn anyrust-analyzer cargo itertools 0.14.0 free/any().<I, F>(iterable: I, f: F) -> bool |
| 223 | where |
| 224 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 225 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#) -> bool, |
| 226 | { |
| 227 | iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(f) |
| 228 | } |
| 229 | |
| 230 | /// Return the maximum value of the iterable. |
| 231 | /// |
| 232 | /// [`IntoIterator`] enabled version of [`Iterator::max`]. |
| 233 | /// |
| 234 | /// ``` |
| 235 | /// use itertools::max; |
| 236 | /// |
| 237 | /// assert_eq!(max(0..10), Some(9)); |
| 238 | /// ``` |
| 239 | pub fn maxrust-analyzer cargo itertools 0.14.0 free/max().<I>(iterable: I) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#> |
| 240 | where |
| 241 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 242 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 243 | { |
| 244 | iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#max().() |
| 245 | } |
| 246 | |
| 247 | /// Return the minimum value of the iterable. |
| 248 | /// |
| 249 | /// [`IntoIterator`] enabled version of [`Iterator::min`]. |
| 250 | /// |
| 251 | /// ``` |
| 252 | /// use itertools::min; |
| 253 | /// |
| 254 | /// assert_eq!(min(0..10), Some(0)); |
| 255 | /// ``` |
| 256 | pub fn minrust-analyzer cargo itertools 0.14.0 free/min().<I>(iterable: I) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#> |
| 257 | where |
| 258 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 259 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 260 | { |
| 261 | iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#min().() |
| 262 | } |
| 263 | |
| 264 | /// Combine all iterator elements into one `String`, separated by `sep`. |
| 265 | /// |
| 266 | /// [`IntoIterator`] enabled version of [`Itertools::join`]. |
| 267 | /// |
| 268 | /// ``` |
| 269 | /// use itertools::join; |
| 270 | /// |
| 271 | /// assert_eq!(join(&[1, 2, 3], ", "), "1, 2, 3"); |
| 272 | /// ``` |
| 273 | #[cfg(feature = "use_alloc")] |
| 274 | pub fn joinrust-analyzer cargo itertools 0.14.0 free/join().<I>(iterable: I, sep: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# |
| 275 | where |
| 276 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 277 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#, |
| 278 | { |
| 279 | iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().joinrust-analyzer cargo itertools 0.14.0 Itertools#join().(sep) |
| 280 | } |
| 281 | |
| 282 | /// Sort all iterator elements into a new iterator in ascending order. |
| 283 | /// |
| 284 | /// [`IntoIterator`] enabled version of [`Itertools::sorted`]. |
| 285 | /// |
| 286 | /// ``` |
| 287 | /// use itertools::sorted; |
| 288 | /// use itertools::assert_equal; |
| 289 | /// |
| 290 | /// assert_equal(sorted("rust".chars()), "rstu".chars()); |
| 291 | /// ``` |
| 292 | #[cfg(feature = "use_alloc")] |
| 293 | pub fn sortedrust-analyzer cargo itertools 0.14.0 free/sorted().<I>(iterable: I) -> VecIntoIterrust-analyzer cargo itertools 0.14.0 free/VecIntoIter#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#> |
| 294 | where |
| 295 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 296 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 297 | { |
| 298 | iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().sortedrust-analyzer cargo itertools 0.14.0 Itertools#sorted().() |
| 299 | } |
| 300 | |
| 301 | /// Sort all iterator elements into a new iterator in ascending order. |
| 302 | /// This sort is unstable (i.e., may reorder equal elements). |
| 303 | /// |
| 304 | /// [`IntoIterator`] enabled version of [`Itertools::sorted_unstable`]. |
| 305 | /// |
| 306 | /// ``` |
| 307 | /// use itertools::sorted_unstable; |
| 308 | /// use itertools::assert_equal; |
| 309 | /// |
| 310 | /// assert_equal(sorted_unstable("rust".chars()), "rstu".chars()); |
| 311 | /// ``` |
| 312 | #[cfg(feature = "use_alloc")] |
| 313 | pub fn sorted_unstablerust-analyzer cargo itertools 0.14.0 free/sorted_unstable().<I>(iterable: I) -> VecIntoIterrust-analyzer cargo itertools 0.14.0 free/VecIntoIter#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#> |
| 314 | where |
| 315 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 316 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 317 | { |
| 318 | iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().sorted_unstablerust-analyzer cargo itertools 0.14.0 Itertools#sorted_unstable().() |
| 319 | } |