Skip to content
masterclass Buddy

Rust · Method

Option::map

Option::map transforms the value inside Some and leaves None unchanged. It returns another Option, so optional control flow can be chained.

Last updated

Since
1.0.0

Syntax

pub fn map<U, F>(self, f: F) -> Option<U>
where
    F: FnOnce(T) -> U

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • Option
  • Option::map_or
  • Option::map_or_else
  • closures
  • and_then

Source: Option in std::option - Rust. Checked 2026-11-03.