Debian Codegraph @

src/trait_impls/std_types.rs

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