-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-collectionsArea: `std::collections`Area: `std::collections`A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
The current doctests for a few methods don't really test anything when they could. The following changes would:
- improve the documentation for programmers by better showing what the results of the functions are
- bring the documentation in line with the equivalent methods for
BTreeMap
, which do include tests like the following - act as two free tests of those methods
The current doctest for HashMap
's into_keys
method can be improved to:
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
map.insert("c", 3);
let mut vec: Vec<&str> = map.into_keys().collect();
vec.sort_unstable();
assert_eq!(vec, ["a", "b", "c"]);
The current doctest for HashMap
's into_values
method can be improved to:
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
map.insert("c", 3);
let mut vec: Vec<i32> = map.into_values().collect();
vec.sort_unstable();
assert_eq!(vec, [1, 2, 3]);
I would submit a pull request, but my computer is broken. Could someone please make these changes?
ccqpeinccqpein
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.