| 1 | macro_rules! first { |
| 2 | (($($first: tt)+) $(, ($($rest: tt)+))*) => { |
| 3 | $($first)+ |
| 4 | }; |
| 5 | } |
| 6 | |
| 7 | macro_rules! skip_first { |
| 8 | (($($first: tt)+) $(, ($($rest: tt)+))*) => { |
| 9 | $($($rest)+)* |
| 10 | }; |
| 11 | } |
| 12 | |
| 13 | macro_rules! impl_struct_of_array_traits { |
| 14 | ( $self_ty: ident , [$($element: ident),+] $(, $phantom: ident)?) => { |
| 15 | impl_struct_of_array_traits!($self_ty<>, [$($element),+] $(, $phantom)?); |
| 16 | }; |
| 17 | ( $self_ty: ident < $($phantom_ty: ident)? > , [$($element: ident),+] $(, $phantom: ident)?) => { |
| 18 | impl<$($phantom_ty,)? T, C> Extend<$self_ty<$($phantom_ty,)? T>> for $self_ty<$($phantom_ty,)? C> |
| 19 | where |
| 20 | C: Extend<T>, |
| 21 | { |
| 22 | #[inline(always)] |
| 23 | fn extend<I: IntoIterator<Item = $self_ty<$($phantom_ty,)? T>>>(&mut self, iter: I) { |
| 24 | let iter = iter.into_iter(); |
| 25 | |
| 26 | for color in iter { |
| 27 | $(self.$element.extend(core::iter::once(color.$element));)+ |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | impl<$($phantom_ty,)? T, C> core::iter::FromIterator<$self_ty<$($phantom_ty,)? T>> for $self_ty<$($phantom_ty,)? C> |
| 33 | where |
| 34 | Self: Extend<$self_ty<$($phantom_ty,)? T>>, |
| 35 | C: Default, |
| 36 | { |
| 37 | #[inline(always)] |
| 38 | fn from_iter<I: IntoIterator<Item = $self_ty<$($phantom_ty,)? T>>>(iter: I) -> Self { |
| 39 | let mut result = Self { |
| 40 | $($element: C::default(),)+ |
| 41 | $($phantom: core::marker::PhantomData)? |
| 42 | }; |
| 43 | result.extend(iter); |
| 44 | |
| 45 | result |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | impl<$($phantom_ty,)? T, const N: usize> IntoIterator for $self_ty<$($phantom_ty,)? [T; N]> |
| 50 | { |
| 51 | type Item = $self_ty<$($phantom_ty,)? T>; |
| 52 | |
| 53 | type IntoIter = Iter<core::array::IntoIter<T, N> $(,$phantom_ty)?>; |
| 54 | |
| 55 | #[inline(always)] |
| 56 | fn into_iter(self) -> Self::IntoIter { |
| 57 | Iter { |
| 58 | $($element: IntoIterator::into_iter(self.$element),)+ |
| 59 | $($phantom: core::marker::PhantomData)? |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | impl<$($phantom_ty,)? T, const N: usize> IntoIterator for crate::alpha::Alpha<$self_ty<$($phantom_ty,)? [T; N]>, [T; N]> |
| 65 | { |
| 66 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? T>, T>; |
| 67 | |
| 68 | type IntoIter = crate::alpha::Iter<Iter<core::array::IntoIter<T, N> $(,$phantom_ty)?>, core::array::IntoIter<T, N>>; |
| 69 | |
| 70 | fn into_iter(self) -> Self::IntoIter { |
| 71 | crate::alpha::Iter { |
| 72 | color: self.color.into_iter(), |
| 73 | alpha: IntoIterator::into_iter(self.alpha) |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | impl<'a, $($phantom_ty,)? T> IntoIterator for $self_ty<$($phantom_ty,)? &'a [T]> |
| 79 | { |
| 80 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 81 | |
| 82 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 83 | |
| 84 | #[inline(always)] |
| 85 | fn into_iter(self) -> Self::IntoIter { |
| 86 | Iter { |
| 87 | $($element: self.$element.into_iter(),)+ |
| 88 | $($phantom: core::marker::PhantomData)? |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | impl<'a, $($phantom_ty,)? T> IntoIterator for crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a [T]>, &'a [T]> |
| 94 | { |
| 95 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 96 | |
| 97 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 98 | |
| 99 | fn into_iter(self) -> Self::IntoIter { |
| 100 | crate::alpha::Iter { |
| 101 | color: self.color.into_iter(), |
| 102 | alpha: self.alpha.into_iter(), |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | impl<'a, $($phantom_ty,)? T> IntoIterator for $self_ty<$($phantom_ty,)? &'a mut [T]> |
| 108 | { |
| 109 | type Item = $self_ty<$($phantom_ty,)? &'a mut T>; |
| 110 | |
| 111 | type IntoIter = Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>; |
| 112 | |
| 113 | #[inline(always)] |
| 114 | fn into_iter(self) -> Self::IntoIter { |
| 115 | Iter { |
| 116 | $($element: self.$element.into_iter(),)+ |
| 117 | $($phantom: core::marker::PhantomData)? |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | impl<'a, $($phantom_ty,)? T> IntoIterator for crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut [T]>, &'a mut [T]> |
| 123 | { |
| 124 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut T>, &'a mut T>; |
| 125 | |
| 126 | type IntoIter = crate::alpha::Iter<Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>, core::slice::IterMut<'a, T>>; |
| 127 | |
| 128 | fn into_iter(self) -> Self::IntoIter { |
| 129 | crate::alpha::Iter { |
| 130 | color: self.color.into_iter(), |
| 131 | alpha: self.alpha.into_iter(), |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | #[cfg(feature = "alloc")] |
| 137 | impl<$($phantom_ty,)? T> IntoIterator for $self_ty<$($phantom_ty,)? alloc::vec::Vec<T>> |
| 138 | { |
| 139 | type Item = $self_ty<$($phantom_ty,)? T>; |
| 140 | |
| 141 | type IntoIter = Iter<alloc::vec::IntoIter<T> $(,$phantom_ty)?>; |
| 142 | |
| 143 | #[inline(always)] |
| 144 | fn into_iter(self) -> Self::IntoIter { |
| 145 | Iter { |
| 146 | $($element: self.$element.into_iter(),)+ |
| 147 | $($phantom: core::marker::PhantomData)? |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | #[cfg(feature = "alloc")] |
| 153 | impl<'a, $($phantom_ty,)? T> IntoIterator for crate::alpha::Alpha<$self_ty<$($phantom_ty,)? alloc::vec::Vec<T>>, alloc::vec::Vec<T>> |
| 154 | { |
| 155 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? T>, T>; |
| 156 | |
| 157 | type IntoIter = crate::alpha::Iter<Iter<alloc::vec::IntoIter<T> $(,$phantom_ty)?>, alloc::vec::IntoIter<T>>; |
| 158 | |
| 159 | fn into_iter(self) -> Self::IntoIter { |
| 160 | crate::alpha::Iter { |
| 161 | color: self.color.into_iter(), |
| 162 | alpha: self.alpha.into_iter(), |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | impl<'a, $($phantom_ty,)? T, const N: usize> IntoIterator for &'a $self_ty<$($phantom_ty,)? [T; N]> |
| 168 | { |
| 169 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 170 | |
| 171 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 172 | |
| 173 | #[inline(always)] |
| 174 | fn into_iter(self) -> Self::IntoIter { |
| 175 | Iter { |
| 176 | $($element: (&self.$element).into_iter(),)+ |
| 177 | $($phantom: core::marker::PhantomData)? |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | impl<'a, $($phantom_ty,)? T, const N: usize> IntoIterator for &'a crate::alpha::Alpha<$self_ty<$($phantom_ty,)? [T; N]>, [T; N]> |
| 183 | { |
| 184 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 185 | |
| 186 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 187 | |
| 188 | fn into_iter(self) -> Self::IntoIter { |
| 189 | crate::alpha::Iter { |
| 190 | color: (&self.color).into_iter(), |
| 191 | alpha: (&self.alpha).into_iter(), |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a $self_ty<$($phantom_ty,)? &'b [T]> |
| 197 | { |
| 198 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 199 | |
| 200 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 201 | |
| 202 | #[inline(always)] |
| 203 | fn into_iter(self) -> Self::IntoIter { |
| 204 | Iter { |
| 205 | $($element: (&self.$element).into_iter(),)+ |
| 206 | $($phantom: core::marker::PhantomData)? |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'b [T]>, &'b [T]> |
| 212 | { |
| 213 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 214 | |
| 215 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 216 | |
| 217 | fn into_iter(self) -> Self::IntoIter { |
| 218 | crate::alpha::Iter { |
| 219 | color: self.color.into_iter(), |
| 220 | alpha: self.alpha.into_iter(), |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a $self_ty<$($phantom_ty,)? &'b mut [T]> |
| 226 | { |
| 227 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 228 | |
| 229 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 230 | |
| 231 | #[inline(always)] |
| 232 | fn into_iter(self) -> Self::IntoIter { |
| 233 | Iter { |
| 234 | $($element: (&*self.$element).into_iter(),)+ |
| 235 | $($phantom: core::marker::PhantomData)? |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'b mut [T]>, &'b mut [T]> |
| 241 | { |
| 242 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 243 | |
| 244 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 245 | |
| 246 | fn into_iter(self) -> Self::IntoIter { |
| 247 | crate::alpha::Iter { |
| 248 | color: (&self.color).into_iter(), |
| 249 | alpha: (&*self.alpha).into_iter(), |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | #[cfg(feature = "alloc")] |
| 255 | impl<'a, $($phantom_ty,)? T> IntoIterator for &'a $self_ty<$($phantom_ty,)? alloc::vec::Vec<T>> |
| 256 | { |
| 257 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 258 | |
| 259 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 260 | |
| 261 | #[inline(always)] |
| 262 | fn into_iter(self) -> Self::IntoIter { |
| 263 | Iter { |
| 264 | $($element: (&self.$element).into_iter(),)+ |
| 265 | $($phantom: core::marker::PhantomData)? |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | #[cfg(feature = "alloc")] |
| 271 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a crate::alpha::Alpha<$self_ty<$($phantom_ty,)? alloc::vec::Vec<T>>, alloc::vec::Vec<T>> |
| 272 | { |
| 273 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 274 | |
| 275 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 276 | |
| 277 | fn into_iter(self) -> Self::IntoIter { |
| 278 | crate::alpha::Iter { |
| 279 | color: (&self.color).into_iter(), |
| 280 | alpha: (&self.alpha).into_iter(), |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | #[cfg(feature = "alloc")] |
| 286 | impl<'a, $($phantom_ty,)? T> IntoIterator for &'a $self_ty<$($phantom_ty,)? alloc::boxed::Box<[T]>> |
| 287 | { |
| 288 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 289 | |
| 290 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 291 | |
| 292 | #[inline(always)] |
| 293 | fn into_iter(self) -> Self::IntoIter { |
| 294 | Iter { |
| 295 | $($element: (&self.$element).into_iter(),)+ |
| 296 | $($phantom: core::marker::PhantomData)? |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | #[cfg(feature = "alloc")] |
| 302 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a crate::alpha::Alpha<$self_ty<$($phantom_ty,)? alloc::boxed::Box<[T]>>, alloc::boxed::Box<[T]>> |
| 303 | { |
| 304 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 305 | |
| 306 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 307 | |
| 308 | fn into_iter(self) -> Self::IntoIter { |
| 309 | crate::alpha::Iter { |
| 310 | color: (&self.color).into_iter(), |
| 311 | alpha: (&self.alpha).into_iter(), |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | impl<'a, $($phantom_ty,)? T, const N: usize> IntoIterator for &'a mut $self_ty<$($phantom_ty,)? [T; N]> |
| 317 | { |
| 318 | type Item = $self_ty<$($phantom_ty,)? &'a mut T>; |
| 319 | |
| 320 | type IntoIter = Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>; |
| 321 | |
| 322 | #[inline(always)] |
| 323 | fn into_iter(self) -> Self::IntoIter { |
| 324 | Iter { |
| 325 | $($element: (&mut self.$element).into_iter(),)+ |
| 326 | $($phantom: core::marker::PhantomData)? |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | impl<'a, $($phantom_ty,)? T, const N: usize> IntoIterator for &'a mut crate::alpha::Alpha<$self_ty<$($phantom_ty,)? [T; N]>, [T; N]> |
| 332 | { |
| 333 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut T>, &'a mut T>; |
| 334 | |
| 335 | type IntoIter = crate::alpha::Iter<Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>, core::slice::IterMut<'a, T>>; |
| 336 | |
| 337 | fn into_iter(self) -> Self::IntoIter { |
| 338 | crate::alpha::Iter { |
| 339 | color: (&mut self.color).into_iter(), |
| 340 | alpha: (&mut self.alpha).into_iter(), |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a mut $self_ty<$($phantom_ty,)? &'b mut [T]> |
| 346 | { |
| 347 | type Item = $self_ty<$($phantom_ty,)? &'a mut T>; |
| 348 | |
| 349 | type IntoIter = Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>; |
| 350 | |
| 351 | #[inline(always)] |
| 352 | fn into_iter(self) -> Self::IntoIter { |
| 353 | Iter { |
| 354 | $($element: self.$element.into_iter(),)+ |
| 355 | $($phantom: core::marker::PhantomData)? |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a mut crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'b mut [T]>, &'b mut [T]> |
| 361 | { |
| 362 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut T>, &'a mut T>; |
| 363 | |
| 364 | type IntoIter = crate::alpha::Iter<Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>, core::slice::IterMut<'a, T>>; |
| 365 | |
| 366 | fn into_iter(self) -> Self::IntoIter { |
| 367 | crate::alpha::Iter { |
| 368 | color: (&mut self.color).into_iter(), |
| 369 | alpha: (self.alpha).into_iter(), |
| 370 | } |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | #[cfg(feature = "alloc")] |
| 375 | impl<'a, $($phantom_ty,)? T> IntoIterator for &'a mut $self_ty<$($phantom_ty,)? alloc::vec::Vec<T>> |
| 376 | { |
| 377 | type Item = $self_ty<$($phantom_ty,)? &'a mut T>; |
| 378 | |
| 379 | type IntoIter = Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>; |
| 380 | |
| 381 | #[inline(always)] |
| 382 | fn into_iter(self) -> Self::IntoIter { |
| 383 | Iter { |
| 384 | $($element: (&mut self.$element).into_iter(),)+ |
| 385 | $($phantom: core::marker::PhantomData)? |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | #[cfg(feature = "alloc")] |
| 391 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a mut crate::alpha::Alpha<$self_ty<$($phantom_ty,)? alloc::vec::Vec<T>>, alloc::vec::Vec<T>> |
| 392 | { |
| 393 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut T>, &'a mut T>; |
| 394 | |
| 395 | type IntoIter = crate::alpha::Iter<Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>, core::slice::IterMut<'a, T>>; |
| 396 | |
| 397 | fn into_iter(self) -> Self::IntoIter { |
| 398 | crate::alpha::Iter { |
| 399 | color: (&mut self.color).into_iter(), |
| 400 | alpha: (&mut self.alpha).into_iter(), |
| 401 | } |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | #[cfg(feature = "alloc")] |
| 406 | impl<'a, $($phantom_ty,)? T> IntoIterator for &'a mut $self_ty<$($phantom_ty,)? alloc::boxed::Box<[T]>> |
| 407 | where |
| 408 | T: 'a |
| 409 | { |
| 410 | type Item = $self_ty<$($phantom_ty,)? &'a mut T>; |
| 411 | |
| 412 | type IntoIter = Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>; |
| 413 | |
| 414 | #[inline(always)] |
| 415 | fn into_iter(self) -> Self::IntoIter { |
| 416 | Iter { |
| 417 | $($element: (&mut *self.$element).into_iter(),)+ |
| 418 | $($phantom: core::marker::PhantomData)? |
| 419 | } |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | #[cfg(feature = "alloc")] |
| 424 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a mut crate::alpha::Alpha<$self_ty<$($phantom_ty,)? alloc::boxed::Box<[T]>>, alloc::boxed::Box<[T]>> |
| 425 | { |
| 426 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut T>, &'a mut T>; |
| 427 | |
| 428 | type IntoIter = crate::alpha::Iter<Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>, core::slice::IterMut<'a, T>>; |
| 429 | |
| 430 | fn into_iter(self) -> Self::IntoIter { |
| 431 | crate::alpha::Iter { |
| 432 | color: (&mut self.color).into_iter(), |
| 433 | alpha: (&mut *self.alpha).into_iter(), |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | #[doc = concat!("An iterator for [`", stringify!($self_ty), "`] values.")] |
| 439 | pub struct Iter<I $(,$phantom_ty)?> { |
| 440 | $(pub(crate) $element: I,)+ |
| 441 | $(pub(crate) $phantom: core::marker::PhantomData<$phantom_ty>)? |
| 442 | } |
| 443 | |
| 444 | impl<I $(,$phantom_ty)?> Iterator for Iter<I $(,$phantom_ty)?> |
| 445 | where |
| 446 | I: Iterator, |
| 447 | { |
| 448 | type Item = $self_ty<$($phantom_ty,)? I::Item>; |
| 449 | |
| 450 | #[inline(always)] |
| 451 | fn next(&mut self) -> Option<Self::Item> { |
| 452 | $(let $element = self.$element.next();)+ |
| 453 | |
| 454 | if let ($(Some($element),)+) = ($($element,)+) { |
| 455 | Some($self_ty { |
| 456 | $($element,)+ |
| 457 | $($phantom: core::marker::PhantomData,)? |
| 458 | }) |
| 459 | } else { |
| 460 | None |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | #[inline(always)] |
| 465 | fn size_hint(&self) -> (usize, Option<usize>) { |
| 466 | let hint = first!($((self.$element)),+).size_hint(); |
| 467 | skip_first!($((debug_assert_eq!(self.$element.size_hint(), hint, "the component iterators have different size hints");)),+); |
| 468 | |
| 469 | hint |
| 470 | } |
| 471 | |
| 472 | #[inline(always)] |
| 473 | fn count(self) -> usize { |
| 474 | let count = first!($((self.$element)),+).count(); |
| 475 | skip_first!($((debug_assert_eq!(self.$element.count(), count, "the component iterators have different counts");)),+); |
| 476 | |
| 477 | count |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | impl<I $(,$phantom_ty)?> DoubleEndedIterator for Iter<I $(,$phantom_ty)?> |
| 482 | where |
| 483 | I: DoubleEndedIterator, |
| 484 | { |
| 485 | #[inline(always)] |
| 486 | fn next_back(&mut self) -> Option<Self::Item> { |
| 487 | $(let $element = self.$element.next_back();)+ |
| 488 | |
| 489 | if let ($(Some($element),)+) = ($($element,)+) { |
| 490 | Some($self_ty { |
| 491 | $($element,)+ |
| 492 | $($phantom: core::marker::PhantomData,)? |
| 493 | }) |
| 494 | } else { |
| 495 | None |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | impl<I $(,$phantom_ty)?> ExactSizeIterator for Iter<I $(,$phantom_ty)?> |
| 501 | where |
| 502 | I: ExactSizeIterator, |
| 503 | { |
| 504 | #[inline(always)] |
| 505 | fn len(&self) -> usize { |
| 506 | let len = first!($((self.$element)),+).len(); |
| 507 | skip_first!($((debug_assert_eq!(self.$element.len(), len, "the component iterators have different lengths");)),+); |
| 508 | |
| 509 | len |
| 510 | } |
| 511 | } |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | macro_rules! impl_struct_of_array_traits_hue { |
| 516 | ( $self_ty: ident, $hue_iter_ty: ident, [$($element: ident),+] $(, $phantom: ident)?) => { |
| 517 | impl_struct_of_array_traits_hue!($self_ty<>, $hue_iter_ty, [$($element),+] $(, $phantom)?); |
| 518 | }; |
| 519 | ( $self_ty: ident < $($phantom_ty: ident)? > , $hue_iter_ty: ident, [$($element: ident),+] $(, $phantom: ident)?) => { |
| 520 | impl<$($phantom_ty,)? T, C> Extend<$self_ty<$($phantom_ty,)? T>> for $self_ty<$($phantom_ty,)? C> |
| 521 | where |
| 522 | C: Extend<T>, |
| 523 | { |
| 524 | #[inline(always)] |
| 525 | fn extend<I: IntoIterator<Item = $self_ty<$($phantom_ty,)? T>>>(&mut self, iter: I) { |
| 526 | let iter = iter.into_iter(); |
| 527 | |
| 528 | for color in iter { |
| 529 | self.hue.extend(core::iter::once(color.hue.into_inner())); |
| 530 | $(self.$element.extend(core::iter::once(color.$element));)+ |
| 531 | } |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | impl<$($phantom_ty,)? T, C> core::iter::FromIterator<$self_ty<$($phantom_ty,)? T>> for $self_ty<$($phantom_ty,)? C> |
| 536 | where |
| 537 | Self: Extend<$self_ty<$($phantom_ty,)? T>>, |
| 538 | C: Default, |
| 539 | { |
| 540 | #[inline(always)] |
| 541 | fn from_iter<I: IntoIterator<Item = $self_ty<$($phantom_ty,)? T>>>(iter: I) -> Self { |
| 542 | let mut result = Self { |
| 543 | hue: C::default().into(), |
| 544 | $($element: C::default(),)+ |
| 545 | $($phantom: core::marker::PhantomData)? |
| 546 | }; |
| 547 | result.extend(iter); |
| 548 | |
| 549 | result |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | impl<$($phantom_ty,)? T, const N: usize> IntoIterator for $self_ty<$($phantom_ty,)? [T; N]> |
| 554 | { |
| 555 | type Item = $self_ty<$($phantom_ty,)? T>; |
| 556 | |
| 557 | type IntoIter = Iter<core::array::IntoIter<T, N> $(,$phantom_ty)?>; |
| 558 | |
| 559 | #[inline(always)] |
| 560 | fn into_iter(self) -> Self::IntoIter { |
| 561 | Iter { |
| 562 | hue: self.hue.into_iter(), |
| 563 | $($element: IntoIterator::into_iter(self.$element),)+ |
| 564 | $($phantom: core::marker::PhantomData)? |
| 565 | } |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | impl<$($phantom_ty,)? T, const N: usize> IntoIterator for crate::alpha::Alpha<$self_ty<$($phantom_ty,)? [T; N]>, [T; N]> |
| 570 | { |
| 571 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? T>, T>; |
| 572 | |
| 573 | type IntoIter = crate::alpha::Iter<Iter<core::array::IntoIter<T, N> $(,$phantom_ty)?>, core::array::IntoIter<T, N>>; |
| 574 | |
| 575 | fn into_iter(self) -> Self::IntoIter { |
| 576 | crate::alpha::Iter { |
| 577 | color: self.color.into_iter(), |
| 578 | alpha: IntoIterator::into_iter(self.alpha) |
| 579 | } |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | impl<'a, $($phantom_ty,)? T> IntoIterator for $self_ty<$($phantom_ty,)? &'a [T]> |
| 584 | { |
| 585 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 586 | |
| 587 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 588 | |
| 589 | #[inline(always)] |
| 590 | fn into_iter(self) -> Self::IntoIter { |
| 591 | Iter { |
| 592 | hue: self.hue.into_iter(), |
| 593 | $($element: self.$element.into_iter(),)+ |
| 594 | $($phantom: core::marker::PhantomData)? |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | impl<'a, $($phantom_ty,)? T> IntoIterator for crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a [T]>, &'a [T]> |
| 600 | { |
| 601 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 602 | |
| 603 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 604 | |
| 605 | fn into_iter(self) -> Self::IntoIter { |
| 606 | crate::alpha::Iter { |
| 607 | color: self.color.into_iter(), |
| 608 | alpha: self.alpha.into_iter(), |
| 609 | } |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | impl<'a, $($phantom_ty,)? T> IntoIterator for $self_ty<$($phantom_ty,)? &'a mut [T]> |
| 614 | { |
| 615 | type Item = $self_ty<$($phantom_ty,)? &'a mut T>; |
| 616 | |
| 617 | type IntoIter = Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>; |
| 618 | |
| 619 | #[inline(always)] |
| 620 | fn into_iter(self) -> Self::IntoIter { |
| 621 | Iter { |
| 622 | hue: self.hue.into_iter(), |
| 623 | $($element: self.$element.into_iter(),)+ |
| 624 | $($phantom: core::marker::PhantomData)? |
| 625 | } |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | impl<'a, $($phantom_ty,)? T> IntoIterator for crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut [T]>, &'a mut [T]> |
| 630 | { |
| 631 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut T>, &'a mut T>; |
| 632 | |
| 633 | type IntoIter = crate::alpha::Iter<Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>, core::slice::IterMut<'a, T>>; |
| 634 | |
| 635 | fn into_iter(self) -> Self::IntoIter { |
| 636 | crate::alpha::Iter { |
| 637 | color: self.color.into_iter(), |
| 638 | alpha: self.alpha.into_iter(), |
| 639 | } |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | #[cfg(feature = "alloc")] |
| 644 | impl<$($phantom_ty,)? T> IntoIterator for $self_ty<$($phantom_ty,)? alloc::vec::Vec<T>> |
| 645 | { |
| 646 | type Item = $self_ty<$($phantom_ty,)? T>; |
| 647 | |
| 648 | type IntoIter = Iter<alloc::vec::IntoIter<T> $(,$phantom_ty)?>; |
| 649 | |
| 650 | #[inline(always)] |
| 651 | fn into_iter(self) -> Self::IntoIter { |
| 652 | Iter { |
| 653 | hue: self.hue.into_iter(), |
| 654 | $($element: self.$element.into_iter(),)+ |
| 655 | $($phantom: core::marker::PhantomData)? |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | #[cfg(feature = "alloc")] |
| 661 | impl<'a, $($phantom_ty,)? T> IntoIterator for crate::alpha::Alpha<$self_ty<$($phantom_ty,)? alloc::vec::Vec<T>>, alloc::vec::Vec<T>> |
| 662 | { |
| 663 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? T>, T>; |
| 664 | |
| 665 | type IntoIter = crate::alpha::Iter<Iter<alloc::vec::IntoIter<T> $(,$phantom_ty)?>, alloc::vec::IntoIter<T>>; |
| 666 | |
| 667 | fn into_iter(self) -> Self::IntoIter { |
| 668 | crate::alpha::Iter { |
| 669 | color: self.color.into_iter(), |
| 670 | alpha: self.alpha.into_iter(), |
| 671 | } |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | impl<'a, $($phantom_ty,)? T, const N: usize> IntoIterator for &'a $self_ty<$($phantom_ty,)? [T; N]> |
| 676 | { |
| 677 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 678 | |
| 679 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 680 | |
| 681 | #[inline(always)] |
| 682 | fn into_iter(self) -> Self::IntoIter { |
| 683 | Iter { |
| 684 | hue: (&self.hue).into_iter(), |
| 685 | $($element: (&self.$element).into_iter(),)+ |
| 686 | $($phantom: core::marker::PhantomData)? |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | impl<'a, $($phantom_ty,)? T, const N: usize> IntoIterator for &'a crate::alpha::Alpha<$self_ty<$($phantom_ty,)? [T; N]>, [T; N]> |
| 692 | { |
| 693 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 694 | |
| 695 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 696 | |
| 697 | fn into_iter(self) -> Self::IntoIter { |
| 698 | crate::alpha::Iter { |
| 699 | color: (&self.color).into_iter(), |
| 700 | alpha: (&self.alpha).into_iter(), |
| 701 | } |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a $self_ty<$($phantom_ty,)? &'b [T]> |
| 706 | { |
| 707 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 708 | |
| 709 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 710 | |
| 711 | #[inline(always)] |
| 712 | fn into_iter(self) -> Self::IntoIter { |
| 713 | Iter { |
| 714 | hue: self.hue.into_iter(), |
| 715 | $($element: (&self.$element).into_iter(),)+ |
| 716 | $($phantom: core::marker::PhantomData)? |
| 717 | } |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'b [T]>, &'b [T]> |
| 722 | { |
| 723 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 724 | |
| 725 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 726 | |
| 727 | fn into_iter(self) -> Self::IntoIter { |
| 728 | crate::alpha::Iter { |
| 729 | color: self.color.into_iter(), |
| 730 | alpha: self.alpha.into_iter(), |
| 731 | } |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a $self_ty<$($phantom_ty,)? &'b mut [T]> |
| 736 | { |
| 737 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 738 | |
| 739 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 740 | |
| 741 | #[inline(always)] |
| 742 | fn into_iter(self) -> Self::IntoIter { |
| 743 | Iter { |
| 744 | hue: (&self.hue).into_iter(), |
| 745 | $($element: (&*self.$element).into_iter(),)+ |
| 746 | $($phantom: core::marker::PhantomData)? |
| 747 | } |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'b mut [T]>, &'b mut [T]> |
| 752 | { |
| 753 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 754 | |
| 755 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 756 | |
| 757 | fn into_iter(self) -> Self::IntoIter { |
| 758 | crate::alpha::Iter { |
| 759 | color: (&self.color).into_iter(), |
| 760 | alpha: (&*self.alpha).into_iter(), |
| 761 | } |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | #[cfg(feature = "alloc")] |
| 766 | impl<'a, $($phantom_ty,)? T> IntoIterator for &'a $self_ty<$($phantom_ty,)? alloc::vec::Vec<T>> |
| 767 | { |
| 768 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 769 | |
| 770 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 771 | |
| 772 | #[inline(always)] |
| 773 | fn into_iter(self) -> Self::IntoIter { |
| 774 | Iter { |
| 775 | hue: (&self.hue).into_iter(), |
| 776 | $($element: (&self.$element).into_iter(),)+ |
| 777 | $($phantom: core::marker::PhantomData)? |
| 778 | } |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | #[cfg(feature = "alloc")] |
| 783 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a crate::alpha::Alpha<$self_ty<$($phantom_ty,)? alloc::vec::Vec<T>>, alloc::vec::Vec<T>> |
| 784 | { |
| 785 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 786 | |
| 787 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 788 | |
| 789 | fn into_iter(self) -> Self::IntoIter { |
| 790 | crate::alpha::Iter { |
| 791 | color: (&self.color).into_iter(), |
| 792 | alpha: (&self.alpha).into_iter(), |
| 793 | } |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | #[cfg(feature = "alloc")] |
| 798 | impl<'a, $($phantom_ty,)? T> IntoIterator for &'a $self_ty<$($phantom_ty,)? alloc::boxed::Box<[T]>> |
| 799 | { |
| 800 | type Item = $self_ty<$($phantom_ty,)? &'a T>; |
| 801 | |
| 802 | type IntoIter = Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>; |
| 803 | |
| 804 | #[inline(always)] |
| 805 | fn into_iter(self) -> Self::IntoIter { |
| 806 | Iter { |
| 807 | hue: (&self.hue).into_iter(), |
| 808 | $($element: (&self.$element).into_iter(),)+ |
| 809 | $($phantom: core::marker::PhantomData)? |
| 810 | } |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | #[cfg(feature = "alloc")] |
| 815 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a crate::alpha::Alpha<$self_ty<$($phantom_ty,)? alloc::boxed::Box<[T]>>, alloc::boxed::Box<[T]>> |
| 816 | { |
| 817 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a T>, &'a T>; |
| 818 | |
| 819 | type IntoIter = crate::alpha::Iter<Iter<core::slice::Iter<'a, T> $(,$phantom_ty)?>, core::slice::Iter<'a, T>>; |
| 820 | |
| 821 | fn into_iter(self) -> Self::IntoIter { |
| 822 | crate::alpha::Iter { |
| 823 | color: (&self.color).into_iter(), |
| 824 | alpha: (&self.alpha).into_iter(), |
| 825 | } |
| 826 | } |
| 827 | } |
| 828 | |
| 829 | impl<'a, $($phantom_ty,)? T, const N: usize> IntoIterator for &'a mut $self_ty<$($phantom_ty,)? [T; N]> |
| 830 | { |
| 831 | type Item = $self_ty<$($phantom_ty,)? &'a mut T>; |
| 832 | |
| 833 | type IntoIter = Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>; |
| 834 | |
| 835 | #[inline(always)] |
| 836 | fn into_iter(self) -> Self::IntoIter { |
| 837 | Iter { |
| 838 | hue: (&mut self.hue).into_iter(), |
| 839 | $($element: (&mut self.$element).into_iter(),)+ |
| 840 | $($phantom: core::marker::PhantomData)? |
| 841 | } |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | impl<'a, $($phantom_ty,)? T, const N: usize> IntoIterator for &'a mut crate::alpha::Alpha<$self_ty<$($phantom_ty,)? [T; N]>, [T; N]> |
| 846 | { |
| 847 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut T>, &'a mut T>; |
| 848 | |
| 849 | type IntoIter = crate::alpha::Iter<Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>, core::slice::IterMut<'a, T>>; |
| 850 | |
| 851 | fn into_iter(self) -> Self::IntoIter { |
| 852 | crate::alpha::Iter { |
| 853 | color: (&mut self.color).into_iter(), |
| 854 | alpha: (&mut self.alpha).into_iter(), |
| 855 | } |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a mut $self_ty<$($phantom_ty,)? &'b mut [T]> |
| 860 | { |
| 861 | type Item = $self_ty<$($phantom_ty,)? &'a mut T>; |
| 862 | |
| 863 | type IntoIter = Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>; |
| 864 | |
| 865 | #[inline(always)] |
| 866 | fn into_iter(self) -> Self::IntoIter { |
| 867 | Iter { |
| 868 | hue: (&mut self.hue).into_iter(), |
| 869 | $($element: self.$element.into_iter(),)+ |
| 870 | $($phantom: core::marker::PhantomData)? |
| 871 | } |
| 872 | } |
| 873 | } |
| 874 | |
| 875 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a mut crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'b mut [T]>, &'b mut [T]> |
| 876 | { |
| 877 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut T>, &'a mut T>; |
| 878 | |
| 879 | type IntoIter = crate::alpha::Iter<Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>, core::slice::IterMut<'a, T>>; |
| 880 | |
| 881 | fn into_iter(self) -> Self::IntoIter { |
| 882 | crate::alpha::Iter { |
| 883 | color: (&mut self.color).into_iter(), |
| 884 | alpha: (self.alpha).into_iter(), |
| 885 | } |
| 886 | } |
| 887 | } |
| 888 | |
| 889 | #[cfg(feature = "alloc")] |
| 890 | impl<'a, $($phantom_ty,)? T> IntoIterator for &'a mut $self_ty<$($phantom_ty,)? alloc::vec::Vec<T>> |
| 891 | { |
| 892 | type Item = $self_ty<$($phantom_ty,)? &'a mut T>; |
| 893 | |
| 894 | type IntoIter = Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>; |
| 895 | |
| 896 | #[inline(always)] |
| 897 | fn into_iter(self) -> Self::IntoIter { |
| 898 | Iter { |
| 899 | hue: (&mut self.hue).into_iter(), |
| 900 | $($element: (&mut self.$element).into_iter(),)+ |
| 901 | $($phantom: core::marker::PhantomData)? |
| 902 | } |
| 903 | } |
| 904 | } |
| 905 | |
| 906 | #[cfg(feature = "alloc")] |
| 907 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a mut crate::alpha::Alpha<$self_ty<$($phantom_ty,)? alloc::vec::Vec<T>>, alloc::vec::Vec<T>> |
| 908 | { |
| 909 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut T>, &'a mut T>; |
| 910 | |
| 911 | type IntoIter = crate::alpha::Iter<Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>, core::slice::IterMut<'a, T>>; |
| 912 | |
| 913 | fn into_iter(self) -> Self::IntoIter { |
| 914 | crate::alpha::Iter { |
| 915 | color: (&mut self.color).into_iter(), |
| 916 | alpha: (&mut self.alpha).into_iter(), |
| 917 | } |
| 918 | } |
| 919 | } |
| 920 | |
| 921 | #[cfg(feature = "alloc")] |
| 922 | impl<'a, $($phantom_ty,)? T> IntoIterator for &'a mut $self_ty<$($phantom_ty,)? alloc::boxed::Box<[T]>> |
| 923 | { |
| 924 | type Item = $self_ty<$($phantom_ty,)? &'a mut T>; |
| 925 | |
| 926 | type IntoIter = Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>; |
| 927 | |
| 928 | #[inline(always)] |
| 929 | fn into_iter(self) -> Self::IntoIter { |
| 930 | Iter { |
| 931 | hue: (&mut self.hue).into_iter(), |
| 932 | $($element: (&mut *self.$element).into_iter(),)+ |
| 933 | $($phantom: core::marker::PhantomData)? |
| 934 | } |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | #[cfg(feature = "alloc")] |
| 939 | impl<'a, 'b, $($phantom_ty,)? T> IntoIterator for &'a mut crate::alpha::Alpha<$self_ty<$($phantom_ty,)? alloc::boxed::Box<[T]>>, alloc::boxed::Box<[T]>> |
| 940 | { |
| 941 | type Item = crate::alpha::Alpha<$self_ty<$($phantom_ty,)? &'a mut T>, &'a mut T>; |
| 942 | |
| 943 | type IntoIter = crate::alpha::Iter<Iter<core::slice::IterMut<'a, T> $(,$phantom_ty)?>, core::slice::IterMut<'a, T>>; |
| 944 | |
| 945 | fn into_iter(self) -> Self::IntoIter { |
| 946 | crate::alpha::Iter { |
| 947 | color: (&mut self.color).into_iter(), |
| 948 | alpha: (&mut *self.alpha).into_iter(), |
| 949 | } |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | #[doc = concat!("An iterator for [`", stringify!($self_ty), "`] values.")] |
| 954 | pub struct Iter<I $(,$phantom_ty)?> { |
| 955 | pub(crate) hue: $hue_iter_ty<I>, |
| 956 | $(pub(crate) $element: I,)+ |
| 957 | $(pub(crate) $phantom: core::marker::PhantomData<$phantom_ty>)? |
| 958 | } |
| 959 | |
| 960 | impl<I $(,$phantom_ty)?> Iterator for Iter<I $(,$phantom_ty)?> |
| 961 | where |
| 962 | I: Iterator, |
| 963 | { |
| 964 | type Item = $self_ty<$($phantom_ty,)? I::Item>; |
| 965 | |
| 966 | #[inline(always)] |
| 967 | fn next(&mut self) -> Option<Self::Item> { |
| 968 | let hue = self.hue.next(); |
| 969 | $(let $element = self.$element.next();)+ |
| 970 | |
| 971 | if let (Some(hue), $(Some($element),)+) = (hue, $($element,)+) { |
| 972 | Some($self_ty {hue $(, $element)+ $(, $phantom: core::marker::PhantomData)?}) |
| 973 | } else { |
| 974 | None |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | #[inline(always)] |
| 979 | fn size_hint(&self) -> (usize, Option<usize>) { |
| 980 | let hint = self.hue.size_hint(); |
| 981 | $(debug_assert_eq!(self.$element.size_hint(), hint, "the component iterators have different size hints");)+ |
| 982 | |
| 983 | hint |
| 984 | } |
| 985 | |
| 986 | #[inline(always)] |
| 987 | fn count(self) -> usize { |
| 988 | let count = self.hue.count(); |
| 989 | $(debug_assert_eq!(self.$element.count(), count, "the component iterators have different counts");)+ |
| 990 | |
| 991 | count |
| 992 | } |
| 993 | } |
| 994 | |
| 995 | impl<I $(,$phantom_ty)?> DoubleEndedIterator for Iter<I $(,$phantom_ty)?> |
| 996 | where |
| 997 | I: DoubleEndedIterator, |
| 998 | { |
| 999 | #[inline(always)] |
| 1000 | fn next_back(&mut self) -> Option<Self::Item> { |
| 1001 | let hue = self.hue.next_back(); |
| 1002 | $(let $element = self.$element.next_back();)+ |
| 1003 | |
| 1004 | if let (Some(hue), $(Some($element),)+) = (hue, $($element,)+) { |
| 1005 | Some($self_ty {hue $(, $element)+ $(, $phantom: core::marker::PhantomData)?}) |
| 1006 | } else { |
| 1007 | None |
| 1008 | } |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | impl<I $(,$phantom_ty)?> ExactSizeIterator for Iter<I $(,$phantom_ty)?> |
| 1013 | where |
| 1014 | I: ExactSizeIterator, |
| 1015 | { |
| 1016 | #[inline(always)] |
| 1017 | fn len(&self) -> usize { |
| 1018 | let len = self.hue.len(); |
| 1019 | $(debug_assert_eq!(self.$element.len(), len, "the component iterators have different lengths");)+ |
| 1020 | |
| 1021 | len |
| 1022 | } |
| 1023 | } |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | macro_rules! impl_struct_of_arrays_methods { |
| 1028 | ( $self_ty: ident , [$($element: ident),+] $(, $phantom: ident)?) => { |
| 1029 | impl_struct_of_arrays_methods!($self_ty<>, [$($element),+] $(, $phantom)?); |
| 1030 | }; |
| 1031 | ( $self_ty: ident < $($phantom_ty: ident)? > , [$($element: ident),+] $(, $phantom: ident)?) => { |
| 1032 | impl<$($phantom_ty,)? C> $self_ty<$($phantom_ty,)? C> { |
| 1033 | /// Return an iterator over the colors in the wrapped collections. |
| 1034 | #[inline(always)] |
| 1035 | pub fn iter<'a>(&'a self) -> <&'a Self as IntoIterator>::IntoIter where &'a Self: IntoIterator { |
| 1036 | self.into_iter() |
| 1037 | } |
| 1038 | |
| 1039 | /// Return an iterator that allows modifying the colors in the wrapped collections. |
| 1040 | #[inline(always)] |
| 1041 | pub fn iter_mut<'a>(&'a mut self) -> <&'a mut Self as IntoIterator>::IntoIter where &'a mut Self: IntoIterator { |
| 1042 | self.into_iter() |
| 1043 | } |
| 1044 | |
| 1045 | /// Get a color, or slice of colors, with references to the components at `index`. See [`slice::get`] for details. |
| 1046 | #[inline(always)] |
| 1047 | pub fn get<'a, I, T>(&'a self, index: I) -> Option<$self_ty<$($phantom_ty,)? &<I as core::slice::SliceIndex<[T]>>::Output>> |
| 1048 | where |
| 1049 | T: 'a, |
| 1050 | C: AsRef<[T]>, |
| 1051 | I: core::slice::SliceIndex<[T]> + Clone, |
| 1052 | { |
| 1053 | $(let $element = self.$element.as_ref().get(index.clone());)+ |
| 1054 | |
| 1055 | if let ($(Some($element),)+) = ($($element,)+) { |
| 1056 | Some($self_ty { |
| 1057 | $($element,)+ |
| 1058 | $($phantom: core::marker::PhantomData,)? |
| 1059 | }) |
| 1060 | } else { |
| 1061 | None |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | /// Get a color, or slice of colors, that allows modifying the components at `index`. See [`slice::get_mut`] for details. |
| 1066 | #[inline(always)] |
| 1067 | pub fn get_mut<'a, I, T>(&'a mut self, index: I) -> Option<$self_ty<$($phantom_ty,)? &mut <I as core::slice::SliceIndex<[T]>>::Output>> |
| 1068 | where |
| 1069 | T: 'a, |
| 1070 | C: AsMut<[T]>, |
| 1071 | I: core::slice::SliceIndex<[T]> + Clone, |
| 1072 | { |
| 1073 | $(let $element = self.$element.as_mut().get_mut(index.clone());)+ |
| 1074 | |
| 1075 | if let ($(Some($element),)+) = ($($element,)+) { |
| 1076 | Some($self_ty { |
| 1077 | $($element,)+ |
| 1078 | $($phantom: core::marker::PhantomData,)? |
| 1079 | }) |
| 1080 | } else { |
| 1081 | None |
| 1082 | } |
| 1083 | } |
| 1084 | } |
| 1085 | |
| 1086 | #[cfg(feature = "alloc")] |
| 1087 | impl<$($phantom_ty,)? T> $self_ty<$($phantom_ty,)? alloc::vec::Vec<T>> { |
| 1088 | /// Create a struct of vectors with a minimum capacity. See [`Vec::with_capacity`] for details. |
| 1089 | #[inline(always)] |
| 1090 | pub fn with_capacity(capacity: usize) -> Self { |
| 1091 | $(let $element = alloc::vec::Vec::with_capacity(capacity);)+ |
| 1092 | |
| 1093 | Self { |
| 1094 | $($element,)+ |
| 1095 | $($phantom: core::marker::PhantomData,)? |
| 1096 | } |
| 1097 | } |
| 1098 | |
| 1099 | /// Push an additional color's components onto the component vectors. See [`Vec::push`] for details. |
| 1100 | #[inline(always)] |
| 1101 | pub fn push(&mut self, value: $self_ty<$($phantom_ty,)? T>) { |
| 1102 | $(self.$element.push(value.$element);)+ |
| 1103 | } |
| 1104 | |
| 1105 | /// Pop a color's components from the component vectors. See [`Vec::pop`] for details. |
| 1106 | #[inline(always)] |
| 1107 | pub fn pop(&mut self) -> Option<$self_ty<$($phantom_ty,)? T>> { |
| 1108 | $(let $element = self.$element.pop();)+ |
| 1109 | |
| 1110 | Some($self_ty { |
| 1111 | $($element: $element?,)+ |
| 1112 | $($phantom: core::marker::PhantomData,)? |
| 1113 | }) |
| 1114 | } |
| 1115 | |
| 1116 | /// Clear the component vectors. See [`Vec::clear`] for details. |
| 1117 | #[inline(always)] |
| 1118 | pub fn clear(&mut self) { |
| 1119 | $(self.$element.clear();)+ |
| 1120 | } |
| 1121 | |
| 1122 | /// Return an iterator that moves colors out of the specified range. |
| 1123 | #[inline(always)] |
| 1124 | pub fn drain<R>(&mut self, range: R) -> Iter<alloc::vec::Drain<T> $(, $phantom_ty)?> |
| 1125 | where |
| 1126 | R: core::ops::RangeBounds<usize> + Clone, |
| 1127 | { |
| 1128 | Iter { |
| 1129 | $($element: self.$element.drain(range.clone()),)+ |
| 1130 | $($phantom: core::marker::PhantomData,)? |
| 1131 | } |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | impl<$($phantom_ty,)? Ct, Ca> crate::Alpha<$self_ty<$($phantom_ty,)? Ct>, Ca> { |
| 1136 | /// Get a color, or slice of colors, with references to the components at `index`. See [`slice::get`] for details. |
| 1137 | #[inline(always)] |
| 1138 | pub fn get<'a, I, T, A>(&'a self, index: I) -> Option<crate::Alpha< |
| 1139 | $self_ty<$($phantom_ty,)? &<I as core::slice::SliceIndex<[T]>>::Output>, |
| 1140 | &<I as core::slice::SliceIndex<[A]>>::Output |
| 1141 | >> |
| 1142 | where |
| 1143 | T: 'a, |
| 1144 | A: 'a, |
| 1145 | Ct: AsRef<[T]>, |
| 1146 | Ca: AsRef<[A]>, |
| 1147 | I: core::slice::SliceIndex<[T]> + core::slice::SliceIndex<[A]> + Clone |
| 1148 | { |
| 1149 | let color = self.color.get(index.clone()); |
| 1150 | let alpha = self.alpha.as_ref().get(index); |
| 1151 | |
| 1152 | if let (Some(color), Some(alpha)) = (color, alpha) { |
| 1153 | Some(crate::Alpha{color, alpha}) |
| 1154 | } else { |
| 1155 | None |
| 1156 | } |
| 1157 | } |
| 1158 | |
| 1159 | /// Get a color, or slice of colors, that allows modifying the components at `index`. See [`slice::get_mut`] for details. |
| 1160 | #[inline(always)] |
| 1161 | pub fn get_mut<'a, I, T, A>(&'a mut self, index: I) -> Option<crate::Alpha< |
| 1162 | $self_ty<$($phantom_ty,)? &mut <I as core::slice::SliceIndex<[T]>>::Output>, |
| 1163 | &mut <I as core::slice::SliceIndex<[A]>>::Output |
| 1164 | >> |
| 1165 | where |
| 1166 | T: 'a, |
| 1167 | A: 'a, |
| 1168 | Ct: AsMut<[T]>, |
| 1169 | Ca: AsMut<[A]>, |
| 1170 | I: core::slice::SliceIndex<[T]> + core::slice::SliceIndex<[A]> + Clone |
| 1171 | { |
| 1172 | let color = self.color.get_mut(index.clone()); |
| 1173 | let alpha = self.alpha.as_mut().get_mut(index); |
| 1174 | |
| 1175 | if let (Some(color), Some(alpha)) = (color, alpha) { |
| 1176 | Some(crate::Alpha{color, alpha}) |
| 1177 | } else { |
| 1178 | None |
| 1179 | } |
| 1180 | } |
| 1181 | } |
| 1182 | |
| 1183 | #[cfg(feature = "alloc")] |
| 1184 | impl<$($phantom_ty,)? T, A> crate::Alpha<$self_ty<$($phantom_ty,)? alloc::vec::Vec<T>>, alloc::vec::Vec<A>> { |
| 1185 | /// Create a struct of vectors with a minimum capacity. See [`Vec::with_capacity`] for details. |
| 1186 | #[inline(always)] |
| 1187 | pub fn with_capacity(capacity: usize) -> Self { |
| 1188 | crate::Alpha { |
| 1189 | color: $self_ty::with_capacity(capacity), |
| 1190 | alpha: alloc::vec::Vec::with_capacity(capacity), |
| 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | /// Push an additional color's components onto the component vectors. See [`Vec::push`] for details. |
| 1195 | #[inline(always)] |
| 1196 | pub fn push(&mut self, value: crate::Alpha<$self_ty<$($phantom_ty,)? T>, A>) { |
| 1197 | self.color.push(value.color); |
| 1198 | self.alpha.push(value.alpha); |
| 1199 | } |
| 1200 | |
| 1201 | /// Pop a color's components from the component vectors. See [`Vec::pop`] for details. |
| 1202 | #[inline(always)] |
| 1203 | pub fn pop(&mut self) -> Option<crate::Alpha<$self_ty<$($phantom_ty,)? T>, A>> { |
| 1204 | let color = self.color.pop(); |
| 1205 | let alpha = self.alpha.pop(); |
| 1206 | |
| 1207 | Some(crate::Alpha { |
| 1208 | color: color?, |
| 1209 | alpha: alpha?, |
| 1210 | }) |
| 1211 | } |
| 1212 | |
| 1213 | /// Clear the component vectors. See [`Vec::clear`] for details. |
| 1214 | #[inline(always)] |
| 1215 | pub fn clear(&mut self) { |
| 1216 | self.color.clear(); |
| 1217 | self.alpha.clear(); |
| 1218 | } |
| 1219 | |
| 1220 | /// Return an iterator that moves colors out of the specified range. |
| 1221 | #[inline(always)] |
| 1222 | pub fn drain<R>(&mut self, range: R) -> crate::alpha::Iter<Iter<alloc::vec::Drain<T> $(, $phantom_ty)?>, alloc::vec::Drain<A>> |
| 1223 | where |
| 1224 | R: core::ops::RangeBounds<usize> + Clone, |
| 1225 | { |
| 1226 | crate::alpha::Iter { |
| 1227 | color: self.color.drain(range.clone()), |
| 1228 | alpha: self.alpha.drain(range), |
| 1229 | } |
| 1230 | } |
| 1231 | } |
| 1232 | }; |
| 1233 | } |
| 1234 | |
| 1235 | macro_rules! impl_struct_of_arrays_methods_hue { |
| 1236 | ( $self_ty: ident , [$($element: ident),+] $(, $phantom: ident)?) => { |
| 1237 | impl_struct_of_arrays_methods_hue!($self_ty<>, [$($element),+] $(, $phantom)?); |
| 1238 | }; |
| 1239 | ( $self_ty: ident < $($phantom_ty: ident)? > , [$($element: ident),+] $(, $phantom: ident)?) => { |
| 1240 | impl<$($phantom_ty,)? C> $self_ty<$($phantom_ty,)? C> { |
| 1241 | /// Return an iterator over the colors in the wrapped collections. |
| 1242 | #[inline(always)] |
| 1243 | pub fn iter<'a>(&'a self) -> <&'a Self as IntoIterator>::IntoIter where &'a Self: IntoIterator { |
| 1244 | self.into_iter() |
| 1245 | } |
| 1246 | |
| 1247 | /// Return an iterator that allows modifying the colors in the wrapped collections. |
| 1248 | #[inline(always)] |
| 1249 | pub fn iter_mut<'a>(&'a mut self) -> <&'a mut Self as IntoIterator>::IntoIter where &'a mut Self: IntoIterator { |
| 1250 | self.into_iter() |
| 1251 | } |
| 1252 | |
| 1253 | /// Get a color, or slice of colors, with references to the components at `index`. See [`slice::get`] for details. |
| 1254 | #[inline(always)] |
| 1255 | pub fn get<'a, I, T>(&'a self, index: I) -> Option<$self_ty<$($phantom_ty,)? &<I as core::slice::SliceIndex<[T]>>::Output>> |
| 1256 | where |
| 1257 | T: 'a, |
| 1258 | C: AsRef<[T]>, |
| 1259 | I: core::slice::SliceIndex<[T]> + Clone, |
| 1260 | { |
| 1261 | let hue = self.hue.get(index.clone()); |
| 1262 | $(let $element = self.$element.as_ref().get(index.clone());)+ |
| 1263 | |
| 1264 | if let (Some(hue) $(, Some($element))+) = (hue $(,$element)+) { |
| 1265 | Some($self_ty {hue $(, $element)+ $(, $phantom: core::marker::PhantomData)?}) |
| 1266 | } else { |
| 1267 | None |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | /// Get a color, or slice of colors, that allows modifying the components at `index`. See [`slice::get_mut`] for details. |
| 1272 | #[inline(always)] |
| 1273 | pub fn get_mut<'a, I, T>(&'a mut self, index: I) -> Option<$self_ty<$($phantom_ty,)? &mut <I as core::slice::SliceIndex<[T]>>::Output>> |
| 1274 | where |
| 1275 | T: 'a, |
| 1276 | C: AsMut<[T]>, |
| 1277 | I: core::slice::SliceIndex<[T]> + Clone, |
| 1278 | { |
| 1279 | let hue = self.hue.get_mut(index.clone()); |
| 1280 | $(let $element = self.$element.as_mut().get_mut(index.clone());)+ |
| 1281 | |
| 1282 | if let (Some(hue) $(, Some($element))+) = (hue $(,$element)+) { |
| 1283 | Some($self_ty {hue $(, $element)+ $(, $phantom: core::marker::PhantomData)?}) |
| 1284 | } else { |
| 1285 | None |
| 1286 | } |
| 1287 | } |
| 1288 | } |
| 1289 | |
| 1290 | #[cfg(feature = "alloc")] |
| 1291 | impl<$($phantom_ty,)? T> $self_ty<$($phantom_ty,)? alloc::vec::Vec<T>> { |
| 1292 | /// Create a struct of vectors with a minimum capacity. See [`Vec::with_capacity`] for details. |
| 1293 | #[inline(always)] |
| 1294 | pub fn with_capacity(capacity: usize) -> Self { |
| 1295 | let hue = alloc::vec::Vec::with_capacity(capacity); |
| 1296 | $(let $element = alloc::vec::Vec::with_capacity(capacity);)+ |
| 1297 | |
| 1298 | Self {hue: hue.into() $(, $element)+ $(, $phantom: core::marker::PhantomData)?} |
| 1299 | } |
| 1300 | |
| 1301 | /// Push an additional color's components onto the component vectors. See [`Vec::push`] for details. |
| 1302 | #[inline(always)] |
| 1303 | pub fn push(&mut self, value: $self_ty<$($phantom_ty,)? T>) { |
| 1304 | self.hue.push(value.hue); |
| 1305 | $(self.$element.push(value.$element);)+ |
| 1306 | } |
| 1307 | |
| 1308 | /// Pop a color's components from the component vectors. See [`Vec::pop`] for details. |
| 1309 | #[inline(always)] |
| 1310 | pub fn pop(&mut self) -> Option<$self_ty<$($phantom_ty,)? T>> { |
| 1311 | let hue = self.hue.pop(); |
| 1312 | $(let $element = self.$element.pop();)+ |
| 1313 | |
| 1314 | Some($self_ty { |
| 1315 | hue: hue?, |
| 1316 | $($element: $element?,)+ |
| 1317 | $($phantom: core::marker::PhantomData,)? |
| 1318 | }) |
| 1319 | } |
| 1320 | |
| 1321 | /// Clear the component vectors. See [`Vec::clear`] for details. |
| 1322 | #[inline(always)] |
| 1323 | pub fn clear(&mut self) { |
| 1324 | self.hue.clear(); |
| 1325 | $(self.$element.clear();)+ |
| 1326 | } |
| 1327 | |
| 1328 | /// Return an iterator that moves colors out of the specified range. |
| 1329 | #[inline(always)] |
| 1330 | pub fn drain<R>(&mut self, range: R) -> Iter<alloc::vec::Drain<T> $(, $phantom_ty)?> |
| 1331 | where |
| 1332 | R: core::ops::RangeBounds<usize> + Clone, |
| 1333 | { |
| 1334 | Iter { |
| 1335 | hue: self.hue.drain(range.clone()), |
| 1336 | $($element: self.$element.drain(range.clone()),)+ |
| 1337 | $($phantom: core::marker::PhantomData,)? |
| 1338 | } |
| 1339 | } |
| 1340 | } |
| 1341 | |
| 1342 | impl<$($phantom_ty,)? Ct, Ca> crate::Alpha<$self_ty<$($phantom_ty,)? Ct>, Ca> { |
| 1343 | /// Get a color, or slice of colors, with references to the components at `index`. See [`slice::get`] for details. |
| 1344 | #[inline(always)] |
| 1345 | pub fn get<'a, I, T, A>(&'a self, index: I) -> Option<crate::Alpha< |
| 1346 | $self_ty<$($phantom_ty,)? &<I as core::slice::SliceIndex<[T]>>::Output>, |
| 1347 | &<I as core::slice::SliceIndex<[A]>>::Output |
| 1348 | >> |
| 1349 | where |
| 1350 | T: 'a, |
| 1351 | A: 'a, |
| 1352 | Ct: AsRef<[T]>, |
| 1353 | Ca: AsRef<[A]>, |
| 1354 | I: core::slice::SliceIndex<[T]> + core::slice::SliceIndex<[A]> + Clone |
| 1355 | { |
| 1356 | let color = self.color.get(index.clone()); |
| 1357 | let alpha = self.alpha.as_ref().get(index); |
| 1358 | |
| 1359 | if let (Some(color), Some(alpha)) = (color, alpha) { |
| 1360 | Some(crate::Alpha{color, alpha}) |
| 1361 | } else { |
| 1362 | None |
| 1363 | } |
| 1364 | } |
| 1365 | |
| 1366 | /// Get a color, or slice of colors, that allows modifying the components at `index`. See [`slice::get_mut`] for details. |
| 1367 | #[inline(always)] |
| 1368 | pub fn get_mut<'a, I, T, A>(&'a mut self, index: I) -> Option<crate::Alpha< |
| 1369 | $self_ty<$($phantom_ty,)? &mut <I as core::slice::SliceIndex<[T]>>::Output>, |
| 1370 | &mut <I as core::slice::SliceIndex<[A]>>::Output |
| 1371 | >> |
| 1372 | where |
| 1373 | T: 'a, |
| 1374 | A: 'a, |
| 1375 | Ct: AsMut<[T]>, |
| 1376 | Ca: AsMut<[A]>, |
| 1377 | I: core::slice::SliceIndex<[T]> + core::slice::SliceIndex<[A]> + Clone |
| 1378 | { |
| 1379 | let color = self.color.get_mut(index.clone()); |
| 1380 | let alpha = self.alpha.as_mut().get_mut(index); |
| 1381 | |
| 1382 | if let (Some(color), Some(alpha)) = (color, alpha) { |
| 1383 | Some(crate::Alpha{color, alpha}) |
| 1384 | } else { |
| 1385 | None |
| 1386 | } |
| 1387 | } |
| 1388 | } |
| 1389 | |
| 1390 | #[cfg(feature = "alloc")] |
| 1391 | impl<$($phantom_ty,)? T, A> crate::Alpha<$self_ty<$($phantom_ty,)? alloc::vec::Vec<T>>, alloc::vec::Vec<A>> { |
| 1392 | /// Create a struct of vectors with a minimum capacity. See [`Vec::with_capacity`] for details. |
| 1393 | #[inline(always)] |
| 1394 | pub fn with_capacity(capacity: usize) -> Self { |
| 1395 | crate::Alpha { |
| 1396 | color: $self_ty::with_capacity(capacity), |
| 1397 | alpha: alloc::vec::Vec::with_capacity(capacity), |
| 1398 | } |
| 1399 | } |
| 1400 | |
| 1401 | /// Push an additional color's components onto the component vectors. See [`Vec::push`] for details. |
| 1402 | #[inline(always)] |
| 1403 | pub fn push(&mut self, value: crate::Alpha<$self_ty<$($phantom_ty,)? T>, A>) { |
| 1404 | self.color.push(value.color); |
| 1405 | self.alpha.push(value.alpha); |
| 1406 | } |
| 1407 | |
| 1408 | /// Pop a color's components from the component vectors. See [`Vec::pop`] for details. |
| 1409 | #[inline(always)] |
| 1410 | pub fn pop(&mut self) -> Option<crate::Alpha<$self_ty<$($phantom_ty,)? T>, A>> { |
| 1411 | let color = self.color.pop(); |
| 1412 | let alpha = self.alpha.pop(); |
| 1413 | |
| 1414 | Some(crate::Alpha { |
| 1415 | color: color?, |
| 1416 | alpha: alpha?, |
| 1417 | }) |
| 1418 | } |
| 1419 | |
| 1420 | /// Clear the component vectors. See [`Vec::clear`] for details. |
| 1421 | #[inline(always)] |
| 1422 | pub fn clear(&mut self) { |
| 1423 | self.color.clear(); |
| 1424 | self.alpha.clear(); |
| 1425 | } |
| 1426 | |
| 1427 | /// Return an iterator that moves colors out of the specified range. |
| 1428 | #[inline(always)] |
| 1429 | pub fn drain<R>(&mut self, range: R) -> crate::alpha::Iter<Iter<alloc::vec::Drain<T> $(, $phantom_ty)?>, alloc::vec::Drain<A>> |
| 1430 | where |
| 1431 | R: core::ops::RangeBounds<usize> + Clone, |
| 1432 | { |
| 1433 | crate::alpha::Iter { |
| 1434 | color: self.color.drain(range.clone()), |
| 1435 | alpha: self.alpha.drain(range), |
| 1436 | } |
| 1437 | } |
| 1438 | } |
| 1439 | }; |
| 1440 | } |
| 1441 | |
| 1442 | #[cfg(test)] |
| 1443 | macro_rules! struct_of_arrays_tests { |
| 1444 | ($color_ty: ident $(<$phantom_ty:ty>)? [$($element: ident),+] $(phantom: $phantom: ident)?, $($values:expr),+) => { |
| 1445 | #[cfg(feature = "alloc")] |
| 1446 | #[test] |
| 1447 | fn collect() { |
| 1448 | let vec_of_colors = vec![$($values.color),+]; |
| 1449 | let color_of_vecs: $color_ty<$($phantom_ty,)? Vec<_>> = vec_of_colors.into_iter().collect(); |
| 1450 | let vec_of_colors: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1451 | |
| 1452 | assert_eq!(vec_of_colors, vec![$($values.color),+]); |
| 1453 | } |
| 1454 | |
| 1455 | #[cfg(feature = "alloc")] |
| 1456 | #[test] |
| 1457 | fn collect_alpha() { |
| 1458 | let vec_of_colors = vec![$($values),+]; |
| 1459 | let color_of_vecs: crate::alpha::Alpha<$color_ty<$($phantom_ty,)? Vec<_>>, Vec<_>> = vec_of_colors.into_iter().collect(); |
| 1460 | let vec_of_colors: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1461 | |
| 1462 | assert_eq!(vec_of_colors, vec![$($values),+]); |
| 1463 | } |
| 1464 | |
| 1465 | |
| 1466 | #[cfg(feature = "alloc")] |
| 1467 | #[test] |
| 1468 | fn extend() { |
| 1469 | let vec_of_colors = vec![$($values.color),+]; |
| 1470 | |
| 1471 | let mut color_of_vecs = $color_ty::<$($phantom_ty,)? Vec<_>>::with_capacity(vec_of_colors.len()); |
| 1472 | color_of_vecs.extend(vec_of_colors); |
| 1473 | |
| 1474 | let vec_of_colors: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1475 | |
| 1476 | assert_eq!(vec_of_colors, vec![$($values.color),+]); |
| 1477 | } |
| 1478 | |
| 1479 | |
| 1480 | #[cfg(feature = "alloc")] |
| 1481 | #[test] |
| 1482 | fn extend_alpha() { |
| 1483 | let vec_of_colors = vec![$($values),+]; |
| 1484 | |
| 1485 | let mut color_of_vecs = crate::alpha::Alpha::<$color_ty<$($phantom_ty,)? Vec<_>>, Vec<_>>::with_capacity(vec_of_colors.len()); |
| 1486 | color_of_vecs.extend(vec_of_colors); |
| 1487 | |
| 1488 | let vec_of_colors: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1489 | |
| 1490 | assert_eq!(vec_of_colors, vec![$($values),+]); |
| 1491 | } |
| 1492 | |
| 1493 | |
| 1494 | #[cfg(feature = "alloc")] |
| 1495 | #[test] |
| 1496 | fn pop_push() { |
| 1497 | let vec_of_colors = vec![$($values.color),+]; |
| 1498 | |
| 1499 | let mut color_of_vecs: $color_ty<$($phantom_ty,)? Vec<_>> = vec_of_colors.into_iter().collect(); |
| 1500 | let last = color_of_vecs.pop().unwrap(); |
| 1501 | color_of_vecs.push(last); |
| 1502 | |
| 1503 | let vec_of_colors: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1504 | |
| 1505 | assert_eq!(vec_of_colors, vec![$($values.color),+]); |
| 1506 | } |
| 1507 | |
| 1508 | |
| 1509 | #[cfg(feature = "alloc")] |
| 1510 | #[test] |
| 1511 | fn pop_push_alpha() { |
| 1512 | let vec_of_colors = vec![$($values),+]; |
| 1513 | |
| 1514 | let mut color_of_vecs: crate::alpha::Alpha<$color_ty<$($phantom_ty,)? Vec<_>>, Vec<_>> = vec_of_colors.into_iter().collect(); |
| 1515 | let last = color_of_vecs.pop().unwrap(); |
| 1516 | color_of_vecs.push(last); |
| 1517 | |
| 1518 | let vec_of_colors: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1519 | |
| 1520 | assert_eq!(vec_of_colors, vec![$($values),+]); |
| 1521 | } |
| 1522 | |
| 1523 | #[cfg(feature = "alloc")] |
| 1524 | #[test] |
| 1525 | fn clear() { |
| 1526 | let vec_of_colors = vec![$($values.color),+]; |
| 1527 | |
| 1528 | let mut color_of_vecs: $color_ty<$($phantom_ty,)? Vec<_>> = vec_of_colors.into_iter().collect(); |
| 1529 | color_of_vecs.clear(); |
| 1530 | |
| 1531 | let vec_of_colors: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1532 | |
| 1533 | assert_eq!(vec_of_colors, vec![]); |
| 1534 | } |
| 1535 | |
| 1536 | #[cfg(feature = "alloc")] |
| 1537 | #[test] |
| 1538 | fn clear_alpha() { |
| 1539 | let vec_of_colors = vec![$($values),+]; |
| 1540 | |
| 1541 | let mut color_of_vecs: crate::alpha::Alpha<$color_ty<$($phantom_ty,)? Vec<_>>, Vec<_>> = vec_of_colors.into_iter().collect(); |
| 1542 | color_of_vecs.clear(); |
| 1543 | |
| 1544 | let vec_of_colors: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1545 | |
| 1546 | assert_eq!(vec_of_colors, vec![]); |
| 1547 | } |
| 1548 | |
| 1549 | |
| 1550 | #[cfg(feature = "alloc")] |
| 1551 | #[test] |
| 1552 | fn drain() { |
| 1553 | let vec_of_colors = vec![$($values.color),+]; |
| 1554 | |
| 1555 | let mut color_of_vecs: $color_ty<$($phantom_ty,)? Vec<_>> = vec_of_colors.into_iter().collect(); |
| 1556 | |
| 1557 | let vec_of_colors1: Vec<_> = color_of_vecs.drain(..).collect(); |
| 1558 | let vec_of_colors2: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1559 | |
| 1560 | assert_eq!(vec_of_colors1, vec![$($values.color),+]); |
| 1561 | assert_eq!(vec_of_colors2, vec![]); |
| 1562 | } |
| 1563 | |
| 1564 | |
| 1565 | #[cfg(feature = "alloc")] |
| 1566 | #[test] |
| 1567 | fn drain_alpha() { |
| 1568 | let vec_of_colors = vec![$($values),+]; |
| 1569 | |
| 1570 | let mut color_of_vecs: crate::alpha::Alpha<$color_ty<$($phantom_ty,)? Vec<_>>, Vec<_>> = vec_of_colors.into_iter().collect(); |
| 1571 | |
| 1572 | let vec_of_colors1: Vec<_> = color_of_vecs.drain(..).collect(); |
| 1573 | let vec_of_colors2: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1574 | |
| 1575 | assert_eq!(vec_of_colors1, vec![$($values),+]); |
| 1576 | assert_eq!(vec_of_colors2, vec![]); |
| 1577 | } |
| 1578 | |
| 1579 | #[cfg(feature = "alloc")] |
| 1580 | #[test] |
| 1581 | fn modify() { |
| 1582 | let vec_of_colors = vec![$($values.color),+]; |
| 1583 | |
| 1584 | let mut color_of_vecs: $color_ty<$($phantom_ty,)? Vec<_>> = vec_of_colors.into_iter().collect(); |
| 1585 | |
| 1586 | for mut color in &mut color_of_vecs { |
| 1587 | color.set(color.copied() + 2.0); |
| 1588 | } |
| 1589 | |
| 1590 | let vec_of_colors: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1591 | |
| 1592 | assert_eq!(vec_of_colors, vec![$($values.color + 2.0),+]); |
| 1593 | } |
| 1594 | |
| 1595 | #[cfg(feature = "alloc")] |
| 1596 | #[test] |
| 1597 | fn modify_alpha() { |
| 1598 | let vec_of_colors = vec![$($values),+]; |
| 1599 | |
| 1600 | let mut color_of_vecs: crate::alpha::Alpha<$color_ty<$($phantom_ty,)? Vec<_>>, Vec<_>> = vec_of_colors.into_iter().collect(); |
| 1601 | |
| 1602 | for mut color in &mut color_of_vecs { |
| 1603 | color.set(color.copied() + 2.0); |
| 1604 | } |
| 1605 | |
| 1606 | let vec_of_colors: Vec<_> = color_of_vecs.into_iter().collect(); |
| 1607 | |
| 1608 | assert_eq!(vec_of_colors, vec![$($values + 2.0),+]); |
| 1609 | } |
| 1610 | |
| 1611 | #[test] |
| 1612 | fn into_iterator() { |
| 1613 | fn expect_move(_: impl Iterator<Item = $color_ty::<$($phantom_ty,)? f32>>){} |
| 1614 | fn expect_ref<'a>(_: impl Iterator<Item = $color_ty::<$($phantom_ty,)? &'a f32>>){} |
| 1615 | fn expect_ref_mut<'a>(_: impl Iterator<Item = $color_ty::<$($phantom_ty,)? &'a mut f32>>){} |
| 1616 | |
| 1617 | let arrays = $color_ty::<$($phantom_ty,)? [f32; 0]>{ |
| 1618 | $($element: Default::default(),)+ |
| 1619 | $($phantom: core::marker::PhantomData,)? |
| 1620 | }; |
| 1621 | let slices = $color_ty::<$($phantom_ty,)? &[f32]>{ |
| 1622 | $($element: Default::default(),)+ |
| 1623 | $($phantom: core::marker::PhantomData,)? |
| 1624 | }; |
| 1625 | let mut_slices = $color_ty::<$($phantom_ty,)? &mut [f32]>{ |
| 1626 | $($element: Default::default(),)+ |
| 1627 | $($phantom: core::marker::PhantomData,)? |
| 1628 | }; |
| 1629 | |
| 1630 | expect_move(arrays.into_iter()); |
| 1631 | expect_ref(slices.into_iter()); |
| 1632 | expect_ref_mut(mut_slices.into_iter()); |
| 1633 | } |
| 1634 | |
| 1635 | #[test] |
| 1636 | fn into_iterator_alpha() { |
| 1637 | use crate::alpha::Alpha; |
| 1638 | |
| 1639 | fn expect_move(_: impl Iterator<Item = Alpha<$color_ty::<$($phantom_ty,)? f32>, f32>>){} |
| 1640 | fn expect_ref<'a>(_: impl Iterator<Item = Alpha<$color_ty::<$($phantom_ty,)? &'a f32>, &'a f32>>){} |
| 1641 | fn expect_ref_mut<'a>(_: impl Iterator<Item = Alpha<$color_ty::<$($phantom_ty,)? &'a mut f32>, &'a mut f32>>){} |
| 1642 | |
| 1643 | let arrays = Alpha::<_, [f32; 0]>{ |
| 1644 | color: $color_ty::<$($phantom_ty,)? [f32; 0]>{ |
| 1645 | $($element: Default::default(),)+ |
| 1646 | $($phantom: core::marker::PhantomData,)? |
| 1647 | }, |
| 1648 | alpha: Default::default(), |
| 1649 | }; |
| 1650 | let slices = Alpha::<_, &[f32]>{ |
| 1651 | color: $color_ty::<$($phantom_ty,)? &[f32]>{ |
| 1652 | $($element: Default::default(),)+ |
| 1653 | $($phantom: core::marker::PhantomData,)? |
| 1654 | }, |
| 1655 | alpha: Default::default(), |
| 1656 | }; |
| 1657 | let mut_slices = Alpha::<_, &mut [f32]>{ |
| 1658 | color: $color_ty::<$($phantom_ty,)? &mut [f32]>{ |
| 1659 | $($element: Default::default(),)+ |
| 1660 | $($phantom: core::marker::PhantomData,)? |
| 1661 | }, |
| 1662 | alpha: Default::default(), |
| 1663 | }; |
| 1664 | |
| 1665 | expect_move(arrays.into_iter()); |
| 1666 | expect_ref(slices.into_iter()); |
| 1667 | expect_ref_mut(mut_slices.into_iter()); |
| 1668 | } |
| 1669 | |
| 1670 | #[test] |
| 1671 | fn into_iterator_ref() { |
| 1672 | fn expect_ref<'a>(_: impl Iterator<Item = $color_ty::<$($phantom_ty,)? &'a f32>>){} |
| 1673 | fn expect_ref_mut<'a>(_: impl Iterator<Item = $color_ty::<$($phantom_ty,)? &'a mut f32>>){} |
| 1674 | |
| 1675 | let mut arrays = $color_ty::<$($phantom_ty,)? [f32; 0]>{ |
| 1676 | $($element: Default::default(),)+ |
| 1677 | $($phantom: core::marker::PhantomData,)? |
| 1678 | }; |
| 1679 | let mut slices = $color_ty::<$($phantom_ty,)? &[f32]>{ |
| 1680 | $($element: Default::default(),)+ |
| 1681 | $($phantom: core::marker::PhantomData,)? |
| 1682 | }; |
| 1683 | let mut mut_slices = $color_ty::<$($phantom_ty,)? &mut [f32]>{ |
| 1684 | $($element: Default::default(),)+ |
| 1685 | $($phantom: core::marker::PhantomData,)? |
| 1686 | }; |
| 1687 | |
| 1688 | expect_ref((&arrays).into_iter()); |
| 1689 | expect_ref((&slices).into_iter()); |
| 1690 | expect_ref((&mut_slices).into_iter()); |
| 1691 | |
| 1692 | expect_ref_mut((&mut arrays).into_iter()); |
| 1693 | expect_ref((&mut slices).into_iter()); |
| 1694 | expect_ref_mut((&mut mut_slices).into_iter()); |
| 1695 | } |
| 1696 | |
| 1697 | #[test] |
| 1698 | fn into_iterator_ref_alpha() { |
| 1699 | use crate::alpha::Alpha; |
| 1700 | |
| 1701 | fn expect_ref<'a>(_: impl Iterator<Item = Alpha<$color_ty::<$($phantom_ty,)? &'a f32>, &'a f32>>){} |
| 1702 | fn expect_ref_mut<'a>(_: impl Iterator<Item = Alpha<$color_ty::<$($phantom_ty,)? &'a mut f32>, &'a mut f32>>){} |
| 1703 | |
| 1704 | let mut arrays = Alpha::<_, [f32; 0]>{ |
| 1705 | color: $color_ty::<$($phantom_ty,)? [f32; 0]>{ |
| 1706 | $($element: Default::default(),)+ |
| 1707 | $($phantom: core::marker::PhantomData,)? |
| 1708 | }, |
| 1709 | alpha: Default::default(), |
| 1710 | }; |
| 1711 | let mut slices = Alpha::<_, &[f32]>{ |
| 1712 | color: $color_ty::<$($phantom_ty,)? &[f32]>{ |
| 1713 | $($element: Default::default(),)+ |
| 1714 | $($phantom: core::marker::PhantomData,)? |
| 1715 | }, |
| 1716 | alpha: Default::default(), |
| 1717 | }; |
| 1718 | let mut mut_slices = Alpha::<_, &mut [f32]>{ |
| 1719 | color: $color_ty::<$($phantom_ty,)? &mut [f32]>{ |
| 1720 | $($element: Default::default(),)+ |
| 1721 | $($phantom: core::marker::PhantomData,)? |
| 1722 | }, |
| 1723 | alpha: Default::default(), |
| 1724 | }; |
| 1725 | |
| 1726 | expect_ref((&arrays).into_iter()); |
| 1727 | expect_ref((&slices).into_iter()); |
| 1728 | expect_ref((&mut_slices).into_iter()); |
| 1729 | |
| 1730 | expect_ref_mut((&mut arrays).into_iter()); |
| 1731 | expect_ref((&mut slices).into_iter()); |
| 1732 | expect_ref_mut((&mut mut_slices).into_iter()); |
| 1733 | } |
| 1734 | |
| 1735 | #[cfg(feature = "alloc")] |
| 1736 | #[test] |
| 1737 | fn into_iterator_alloc() { |
| 1738 | fn expect_move(_: impl Iterator<Item = $color_ty::<$($phantom_ty,)? f32>>){} |
| 1739 | fn expect_ref<'a>(_: impl Iterator<Item = $color_ty::<$($phantom_ty,)? &'a f32>>){} |
| 1740 | |
| 1741 | let vecs = $color_ty::<$($phantom_ty,)? Vec<f32>>{ |
| 1742 | $($element: Default::default(),)+ |
| 1743 | $($phantom: core::marker::PhantomData,)? |
| 1744 | }; |
| 1745 | let boxed_slices = $color_ty::<$($phantom_ty,)? Box<[f32]>>{ |
| 1746 | $($element: Default::default(),)+ |
| 1747 | $($phantom: core::marker::PhantomData,)? |
| 1748 | }; |
| 1749 | |
| 1750 | expect_move(vecs.into_iter()); |
| 1751 | expect_ref(boxed_slices.into_iter()); |
| 1752 | } |
| 1753 | |
| 1754 | #[cfg(feature = "alloc")] |
| 1755 | #[test] |
| 1756 | fn into_iterator_alloc_alpha() { |
| 1757 | use crate::alpha::Alpha; |
| 1758 | |
| 1759 | fn expect_move(_: impl Iterator<Item = Alpha<$color_ty::<$($phantom_ty,)? f32>, f32>>){} |
| 1760 | fn expect_ref<'a>(_: impl Iterator<Item = Alpha<$color_ty::<$($phantom_ty,)? &'a f32>, &'a f32>>){} |
| 1761 | |
| 1762 | let vecs = Alpha::<_, Vec<f32>>{ |
| 1763 | color: $color_ty::<$($phantom_ty,)? Vec<f32>>{ |
| 1764 | $($element: Default::default(),)+ |
| 1765 | $($phantom: core::marker::PhantomData,)? |
| 1766 | }, |
| 1767 | alpha: Default::default(), |
| 1768 | }; |
| 1769 | let boxed_slices = Alpha::<_, Box<[f32]>>{ |
| 1770 | color: $color_ty::<$($phantom_ty,)? Box<[f32]>>{ |
| 1771 | $($element: Default::default(),)+ |
| 1772 | $($phantom: core::marker::PhantomData,)? |
| 1773 | }, |
| 1774 | alpha: Default::default(), |
| 1775 | }; |
| 1776 | |
| 1777 | expect_move(vecs.into_iter()); |
| 1778 | expect_ref(boxed_slices.into_iter()); |
| 1779 | } |
| 1780 | |
| 1781 | #[cfg(feature = "alloc")] |
| 1782 | #[test] |
| 1783 | fn into_iterator_alloc_ref() { |
| 1784 | fn expect_ref<'a>(_: impl Iterator<Item = $color_ty::<$($phantom_ty,)? &'a f32>>){} |
| 1785 | fn expect_ref_mut<'a>(_: impl Iterator<Item = $color_ty::<$($phantom_ty,)? &'a mut f32>>){} |
| 1786 | |
| 1787 | let mut vecs = $color_ty::<$($phantom_ty,)? Vec<f32>>{ |
| 1788 | $($element: Default::default(),)+ |
| 1789 | $($phantom: core::marker::PhantomData,)? |
| 1790 | }; |
| 1791 | let mut boxed_slices = $color_ty::<$($phantom_ty,)? Box<[f32]>>{ |
| 1792 | $($element: Default::default(),)+ |
| 1793 | $($phantom: core::marker::PhantomData,)? |
| 1794 | }; |
| 1795 | |
| 1796 | expect_ref((&vecs).into_iter()); |
| 1797 | expect_ref((&boxed_slices).into_iter()); |
| 1798 | |
| 1799 | expect_ref_mut((&mut vecs).into_iter()); |
| 1800 | expect_ref_mut((&mut boxed_slices).into_iter()); |
| 1801 | } |
| 1802 | |
| 1803 | #[cfg(feature = "alloc")] |
| 1804 | #[test] |
| 1805 | fn into_iterator_alloc_ref_alpha() { |
| 1806 | use crate::alpha::Alpha; |
| 1807 | |
| 1808 | fn expect_ref<'a>(_: impl Iterator<Item = Alpha<$color_ty::<$($phantom_ty,)? &'a f32>, &'a f32>>){} |
| 1809 | fn expect_ref_mut<'a>(_: impl Iterator<Item = Alpha<$color_ty::<$($phantom_ty,)? &'a mut f32>, &'a mut f32>>){} |
| 1810 | |
| 1811 | let mut vecs = Alpha::<_, Vec<f32>>{ |
| 1812 | color: $color_ty::<$($phantom_ty,)? Vec<f32>>{ |
| 1813 | $($element: Default::default(),)+ |
| 1814 | $($phantom: core::marker::PhantomData,)? |
| 1815 | }, |
| 1816 | alpha: Default::default(), |
| 1817 | }; |
| 1818 | let mut boxed_slices = Alpha::<_, Box<[f32]>>{ |
| 1819 | color: $color_ty::<$($phantom_ty,)? Box<[f32]>>{ |
| 1820 | $($element: Default::default(),)+ |
| 1821 | $($phantom: core::marker::PhantomData,)? |
| 1822 | }, |
| 1823 | alpha: Default::default(), |
| 1824 | }; |
| 1825 | |
| 1826 | expect_ref((&vecs).into_iter()); |
| 1827 | expect_ref((&boxed_slices).into_iter()); |
| 1828 | |
| 1829 | expect_ref_mut((&mut vecs).into_iter()); |
| 1830 | expect_ref_mut((&mut boxed_slices).into_iter()); |
| 1831 | } |
| 1832 | } |
| 1833 | } |