RS.CLIPPY.UNNECESSARY_MAP_ON_CONSTRUCTOR

Using `map`/`map_err` on `Option` or `Result` constructors

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: unnecessary_map_on_constructor. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Suggests removing the use of a map() (or map_err()) method when an Option or Result is being constructed.

Why is this bad?

It introduces unnecessary complexity. Instead, the function can be called before constructing the Option or Result from its return value.

Example

Some(4).map(i32::swap_bytes)

Use instead:

Some(i32::swap_bytes(4))