about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorAlexis Beingessner <a.beingessner@gmail.com>2015-03-20 13:43:01 -0400
committerAlexis <a.beingessner@gmail.com>2015-03-27 07:42:03 -0400
commit1b98f6da7af8cea31066588776b7190c511455b1 (patch)
tree59e9a6e2b8803eea091517ba75cfea54e59faa6f /src/libcollections
parent93cdf1f2783e3a863929a5ef2032e7de752e4e40 (diff)
downloadrust-1b98f6da7af8cea31066588776b7190c511455b1.tar.gz
rust-1b98f6da7af8cea31066588776b7190c511455b1.zip
default => or_insert per RFC
Diffstat (limited to 'src/libcollections')
-rw-r--r--src/libcollections/btree/map.rs8
-rw-r--r--src/libcollections/vec_map.rs8
2 files changed, 8 insertions, 8 deletions
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs
index 1c484d5dd5e..04a692cc3ae 100644
--- a/src/libcollections/btree/map.rs
+++ b/src/libcollections/btree/map.rs
@@ -1146,7 +1146,7 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
     #[unstable(feature = "std_misc",
                reason = "will soon be replaced by or_insert")]
     #[deprecated(since = "1.0",
-                reason = "replaced with more ergonomic `default` and `default_with`")]
+                reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
     /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
     pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
         match self {
@@ -1159,7 +1159,7 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
                reason = "matches entry v3 specification, waiting for dust to settle")]
     /// Ensures a value is in the entry by inserting the default if empty, and returns
     /// a mutable reference to the value in the entry.
-    pub fn default(self, default: V) -> &'a mut V {
+    pub fn or_insert(self, default: V) -> &'a mut V {
         match self {
             Occupied(entry) => entry.into_mut(),
             Vacant(entry) => entry.insert(default),
@@ -1170,7 +1170,7 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
                reason = "matches entry v3 specification, waiting for dust to settle")]
     /// Ensures a value is in the entry by inserting the result of the default function if empty,
     /// and returns a mutable reference to the value in the entry.
-    pub fn default_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
+    pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
         match self {
             Occupied(entry) => entry.into_mut(),
             Vacant(entry) => entry.insert(default()),
@@ -1592,7 +1592,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
     ///
     /// // count the number of occurrences of letters in the vec
     /// for x in vec!["a","b","a","c","a","b"] {
-    ///     *count.entry(x).default(0) += 1;
+    ///     *count.entry(x).or_insert(0) += 1;
     /// }
     ///
     /// assert_eq!(count["a"], 3);
diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs
index 94dd997947c..58f9101d1d3 100644
--- a/src/libcollections/vec_map.rs
+++ b/src/libcollections/vec_map.rs
@@ -637,7 +637,7 @@ impl<V> VecMap<V> {
     ///
     /// // count the number of occurrences of numbers in the vec
     /// for x in vec![1, 2, 1, 2, 3, 4, 1, 2, 4] {
-    ///     *count.entry(x).default(0) += 1;
+    ///     *count.entry(x).or_insert(0) += 1;
     /// }
     ///
     /// assert_eq!(count[1], 3);
@@ -667,7 +667,7 @@ impl<'a, V> Entry<'a, V> {
     #[unstable(feature = "collections",
                reason = "will soon be replaced by or_insert")]
     #[deprecated(since = "1.0",
-                reason = "replaced with more ergonomic `default` and `default_with`")]
+                reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
     /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
     pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, V>> {
         match self {
@@ -680,7 +680,7 @@ impl<'a, V> Entry<'a, V> {
                reason = "matches entry v3 specification, waiting for dust to settle")]
     /// Ensures a value is in the entry by inserting the default if empty, and returns
     /// a mutable reference to the value in the entry.
-    pub fn default(self, default: V) -> &'a mut V {
+    pub fn or_insert(self, default: V) -> &'a mut V {
         match self {
             Occupied(entry) => entry.into_mut(),
             Vacant(entry) => entry.insert(default),
@@ -691,7 +691,7 @@ impl<'a, V> Entry<'a, V> {
                reason = "matches entry v3 specification, waiting for dust to settle")]
     /// Ensures a value is in the entry by inserting the result of the default function if empty,
     /// and returns a mutable reference to the value in the entry.
-    pub fn default_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
+    pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
         match self {
             Occupied(entry) => entry.into_mut(),
             Vacant(entry) => entry.insert(default()),