Skip to content

Commit 88019a7

Browse files
committed
Add #[must_use] to Array::map
The output of Array::map is intended to be an array of the same size, and does not modify the original in place nor is it intended for side-effects. Thus, under normal circumstances it should be consumed. See [discussion](https://internals.rust-lang.org/t/array-map-annotate-with-must-use/22813/26). Attaching to tracking issue #75243
1 parent 8405332 commit 88019a7

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

library/core/src/array/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ impl<T, const N: usize> [T; N] {
531531
/// let y = x.map(|v| v.len());
532532
/// assert_eq!(y, [6, 9, 3, 3]);
533533
/// ```
534+
#[must_use]
534535
#[stable(feature = "array_map", since = "1.55.0")]
535536
pub fn map<F, U>(self, f: F) -> [U; N]
536537
where

0 commit comments

Comments
 (0)