Iterator::map makes note that map is lazy. Option::map and Result::map aren't lazy but this contrast isn't noted in the documentation

I did some tests but it caused me confusion earlier. In retrospect it's obvious considering how they're just enums but for novices I think it would be helpful to note this difference.

2 Likes

I think it's reasonable to submit a PR for this.

1 Like

What would it even mean for Option::map or Result::map to be lazy?

3 Likes

They'd have to return a lazy adapter rather than their own type for that to be possible (and indeed they already do, and that lazy adapter is called Iterator, you just have to call iter/iter_mut/into_iter first to make your operations lazy!)

I can understand the question - looking at the return type, they can't be lazy. But since the question is asked, I guess it's not always what you see, you don't always look at the types that way.

4 Likes