Skip to content

Conversation

@tshepang
Copy link
Member

No description provided.

@rust-highfive
Copy link
Contributor

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this even being made into a String?

@Gankra
Copy link
Contributor

Gankra commented May 31, 2015

It's not clear to me that this really "improves" anything. It just makes the example more complicated.

@tshepang
Copy link
Member Author

num_as_int tells me the string 10 is now represented as the int 10. This is more sensible than checking the length of that string.

It's also nice to do an assert there, so we actually make use of those bindings, instead of just assign values.

BTW, feel free to improve this example.

@Gankra
Copy link
Contributor

Gankra commented Jun 1, 2015

I agree the variable names are unfortunate. How about:

/// let maybe_some_string = Some("hello!".to_string());
/// let maybe_some_len = maybe_some_string.map(|s| s.len());
///
/// assert_eq!(maybe_some_len, Some(6));

@tshepang
Copy link
Member Author

tshepang commented Jun 1, 2015

nice suggestion... done!

@Gankra
Copy link
Contributor

Gankra commented Jun 1, 2015

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jun 1, 2015

📌 Commit 8221715 has been approved by Gankro

Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 2, 2015
bors added a commit that referenced this pull request Jun 2, 2015
@bors bors merged commit 8221715 into rust-lang:master Jun 2, 2015
@tshepang tshepang deleted the option-map-example branch June 2, 2015 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants