Skip to content

Section needs more explanation #1278

Open
@zwhitchcox

Description

@zwhitchcox

On the page Option Result, the last example doesn't really have an explanation for the new combinators introduced. Namely, map_or.

Also, within the map_or, there is a closure function with no real explanation either.

|r| r.map(Some)

I don't really understand what is going on here.

The main line that needs explanation is

let opt = opt.map_or(Ok(None), |r| r.map(Some))?;

Like, what exactly is happening here? I've been staring at it for about 15 minutes, but I can't figure it out.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions