jonhoo / flurry

A port of Java's ConcurrentHashMap to Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Match up documentation with that from std::collections::HashMap

jonhoo opened this issue · comments

flurry::HashMap provides many of the same methods as std::collections::HashMap. We probably want to copy over both text and examples from the documentation from std over into flurry, since the Rust devs have already gone through a lot of care to make them good. We will probably also try to incorporate some of the documentation on the type std::collections::HashMap itself onto flurry::HashMap.

As a part of this process, we should also make sure to call out ways in which the methods on flurry::HashMap differs from those on the std map. Some things to consider:

  • If the method takes a Guard, briefly explain how to get a Guard (epoch::pin; also shown in the example), and refer to the crate-level docs.
  • If the standard library method takes a &mut self, and we take a &self, call this out, and explain that the method can be called from multiple threads concurrently.
  • For pretty much every method that reads from (like get()), aggregates over (like len()), or iterates over (like .iter()) the map, add some text along these lines:

    This method, like most methods in flurry, can be executed concurrently with modifications to the underlying map. If such concurrent modification occurs, this method may return unexpected results. See the "Consistency" section in the crate-level documentation for details.

When writing this documentation, you can use intra-rustdoc links liberally.
A quick introduction to the syntax:

/// This becomes a link to the [`HashMap`] type imported in the current file.
/// This becomes a link to the [same type](HashMap) but with different text.
/// The above is handy for referring to a [`method()`](HashMap::method).
/// You can also refer to a type elsewhere, like [`std::collections::HashMap`].
/// For links to [crate-level documentation](../index.html), use a relative URL.

I'd like to contribute on this issue.

@Arthamys Excellent, thank you! Documentation is extremely important, and I'll take any and all help I can get.

Closed in #57