Transforms the value inside an Option using the provided function. If the Option is Some(value), returns Some(f(value)). If the Option is None, returns None.
Option
Some(value)
Some(f(value))
None
The function to apply to the value if it exists
A new Option containing the transformed value
Transforms the value inside an
Option
using the provided function. If theOption
isSome(value)
, returnsSome(f(value))
. If theOption
isNone
, returnsNone
.