Skip to content

Add a doctest for the entry method of BTreeMap. #19711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

jbranchaud
Copy link
Contributor

No description provided.

@alexcrichton
Copy link
Member

r? @gankro

/// match map.entry("b") {
/// Entry::Vacant(_) => unreachable!(),
/// Entry::Occupied(view) => assert_eq!(*view.get(), 2u),
/// }
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't very idiomatic "entry" code, to be honest. Generally when you're working with entry you're genuinely uncertain if the value is contained, and have something useful to do in both cases. If you "know" the value is-or-isn't there, you should be using indexing or insert.

See the top-level collection docs for some examples I wrote.

@Gankra
Copy link
Contributor

Gankra commented Dec 22, 2014

@jbranchaud ping

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Dec 22, 2014
…entry

This is an updated version of rust-lang#19711. The merge and subsequent rebase on that branch were more trouble than they were worth, so I am just resubmitting the relevant change here.

If this PR is accepted, then rust-lang#19711 can be closed.

/cc @gankro
@csouth3
Copy link
Contributor

csouth3 commented Dec 25, 2014

This can be closed now. #20134 landed.

@sfackler sfackler closed this Dec 25, 2014
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