fix doc example

master
Avril 4 years ago
parent d6dfb89159
commit 1be0750563
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -2,10 +2,12 @@
name = "smallmap"
description = "Small byte-sized generic key-value map type"
keywords = ["map", "table", "small", "key", "value"]
repository = "https://git.flanchan.moe/flanchan/smallmap"
homepage= "https://git.flanchan.moe/flanchan/smallmap"
version = "1.0.0"
authors = ["Avril <flanchan@cumallover.me>"]
edition = "2018"
license = "MIT"
[dependencies]

@ -12,7 +12,7 @@ fn max_char(chars: &str) -> (char, usize)
{
let mut map = Map::new();
for x in chars.chars() {
*map.entry(x).insert_or(0usize) += 1;
*map.entry(x).or_insert(0usize) += 1;
}
map.into_iter().max_by_key(|(k, v)| v).unwrap_or_default()

@ -13,10 +13,10 @@
//! {
//! let mut map = Map::new();
//! for x in chars.chars() {
//! *map.entry(x).insert_or(0usize) += 1;
//! *map.entry(x).or_insert(0usize) += 1;
//! }
//!
//! map.into_iter().max_by_key(|(k, v)| v).unwrap_or_default()
//! map.into_iter().max_by_key(|&(_, v)| v).unwrap_or_default()
//! }
//! ```
//!

Loading…
Cancel
Save