about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorhedgehog1024 <hedgehog1024@scryptmail.com>2018-02-12 22:27:33 +0300
committerGitHub <noreply@github.com>2018-02-12 22:27:33 +0300
commit4360dfa126ba5d26a520e8a0d2dd9680081dad0d (patch)
treeb80e9e26e877742f41dc8952378750808f8dca7b /src/doc
parent862132be72d4de87330e31d53489b8c718a6663e (diff)
downloadrust-4360dfa126ba5d26a520e8a0d2dd9680081dad0d.tar.gz
rust-4360dfa126ba5d26a520e8a0d2dd9680081dad0d.zip
Delete information about 'entry_and_modify' from Unstable book
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/unstable-book/src/library-features/entry-and-modify.md77
1 files changed, 0 insertions, 77 deletions
diff --git a/src/doc/unstable-book/src/library-features/entry-and-modify.md b/src/doc/unstable-book/src/library-features/entry-and-modify.md
deleted file mode 100644
index 1280c71e83c..00000000000
--- a/src/doc/unstable-book/src/library-features/entry-and-modify.md
+++ /dev/null
@@ -1,77 +0,0 @@
-# `entry_and_modify`
-
-The tracking issue for this feature is: [#44733]
-
-[#44733]: https://github.com/rust-lang/rust/issues/44733
-
-------------------------
-
-This introduces a new method for the Entry API of maps
-(`std::collections::HashMap` and `std::collections::BTreeMap`), so that
-occupied entries can be modified before any potential inserts into the
-map.
-
-For example:
-
-```rust
-#![feature(entry_and_modify)]
-# fn main() {
-use std::collections::HashMap;
-
-struct Foo {
-    new: bool,
-}
-
-let mut map: HashMap<&str, Foo> = HashMap::new();
-
-map.entry("quux")
-   .and_modify(|e| e.new = false)
-   .or_insert(Foo { new: true });
-# }
-```
-
-This is not possible with the stable API alone since inserting a default
-_before_ modifying the `new` field would mean we would lose the default state:
-
-```rust
-# fn main() {
-use std::collections::HashMap;
-
-struct Foo {
-    new: bool,
-}
-
-let mut map: HashMap<&str, Foo> = HashMap::new();
-
-map.entry("quux").or_insert(Foo { new: true }).new = false;
-# }
-```
-
-In the above code the `new` field will never be `true`, even though we only
-intended to update that field to `false` for previously extant entries.
-
-To achieve the same effect as `and_modify` we would have to manually match
-against the `Occupied` and `Vacant` variants of the `Entry` enum, which is
-a little less user-friendly, and much more verbose:
-
-```rust
-# fn main() {
-use std::collections::HashMap;
-use std::collections::hash_map::Entry;
-
-struct Foo {
-    new: bool,
-}
-
-let mut map: HashMap<&str, Foo> = HashMap::new();
-
-match map.entry("quux") {
-    Entry::Occupied(entry) => {
-        entry.into_mut().new = false;
-    },
-    Entry::Vacant(entry) => {
-        entry.insert(Foo { new: true });
-    },
-};
-# }
-```