The output has a length equal to that of the slice, with the same capacity as `A`.
(slice: &[T])
| 1464 | /// The output has a length equal to that of the slice, with the same capacity |
| 1465 | /// as `A`. |
| 1466 | fn try_from(slice: &[T]) -> Result<Self, Self::Error> { |
| 1467 | if slice.len() > A::CAPACITY { |
| 1468 | Err(TryFromSliceError(())) |
| 1469 | } else { |
| 1470 | let mut arr = ArrayVec::new(); |
| 1471 | // We do not use ArrayVec::extend_from_slice, because it looks like LLVM |
| 1472 | // fails to deduplicate all the length-checking logic between the |
| 1473 | // above if and the contents of that method, thus producing much |
| 1474 | // slower code. Unlike many of the other optimizations in this |
| 1475 | // crate, this one is worth keeping an eye on. I see no reason, for |
| 1476 | // any element type, that these should produce different code. But |
| 1477 | // they do. (rustc 1.51.0) |
| 1478 | arr.set_len(slice.len()); |
| 1479 | arr.as_mut_slice().clone_from_slice(slice); |
| 1480 | Ok(arr) |
| 1481 | } |
| 1482 | } |
| 1483 | } |
| 1484 | |
| 1485 | impl<A: Array> FromIterator<A::Item> for ArrayVec<A> { |
nothing calls this directly
no test coverage detected