Skip to content

refactor(map): deprecate op-get for future migration #2017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions builtin/builtin.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ impl Map {
keys[K, V](Self[K, V]) -> Iter[K]
new[K, V](capacity~ : Int = ..) -> Self[K, V]
of[K : Hash + Eq, V](FixedArray[(K, V)]) -> Self[K, V]
#deprecated
op_get[K : Hash + Eq, V](Self[K, V], K) -> V?
op_set[K : Hash + Eq, V](Self[K, V], K, V) -> Unit
remove[K : Hash + Eq, V](Self[K, V], K) -> Unit
Expand Down
1 change: 1 addition & 0 deletions builtin/linked_hash_map.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ pub fn Map::get[K : Hash + Eq, V](self : Map[K, V], key : K) -> V? {
}

///|
#deprecated("Use `get` instead. `op_get` will return `V` instead of `Option[V]` in the future.")
pub fn Map::op_get[K : Hash + Eq, V](self : Map[K, V], key : K) -> V? {
self.get(key)
}
Expand Down
1 change: 1 addition & 0 deletions hashmap/hashmap.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ fn get_with_hash[K : Hash + Eq, V](self : T[K, V], key : K, hash : Int) -> V? {
/// inspect!(map["nonexistent"], content="None")
/// }
/// ```
#deprecated("Use `get` instead. `op_get` will return `V` instead of `Option[V]` in the future.")
pub fn op_get[K : Hash + Eq, V](self : T[K, V], key : K) -> V? {
self.get(key)
}
Expand Down
2 changes: 2 additions & 0 deletions hashmap/hashmap.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fn new[K, V](capacity~ : Int = ..) -> T[K, V]

fn of[K : Eq + Hash, V](FixedArray[(K, V)]) -> T[K, V]

#deprecated
fn op_get[K : Hash + Eq, V](T[K, V], K) -> V?

fn op_set[K : Hash + Eq, V](T[K, V], K, V) -> Unit
Expand Down Expand Up @@ -64,6 +65,7 @@ impl T {
is_empty[K, V](Self[K, V]) -> Bool
iter[K, V](Self[K, V]) -> Iter[(K, V)]
iter2[K, V](Self[K, V]) -> Iter2[K, V]
#deprecated
op_get[K : Hash + Eq, V](Self[K, V], K) -> V?
op_set[K : Hash + Eq, V](Self[K, V], K, V) -> Unit
remove[K : Hash + Eq, V](Self[K, V], K) -> Unit
Expand Down
1 change: 1 addition & 0 deletions immut/hashmap/HAMT.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub fn get[K : Eq + Hash, V](self : T[K, V], key : K) -> V? {
}

///|
#deprecated("Use `get` instead. `op_get` will return `V` instead of `Option[V]` in the future.")
pub fn op_get[K : Eq + Hash, V](self : T[K, V], key : K) -> V? {
self.get(key)
}
Expand Down
2 changes: 2 additions & 0 deletions immut/hashmap/hashmap.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fn new[K, V]() -> T[K, V]

fn of[K : Eq + Hash, V](FixedArray[(K, V)]) -> T[K, V]

#deprecated
fn op_get[K : Eq + Hash, V](T[K, V], K) -> V?

fn remove[K : Eq + Hash, V](T[K, V], K) -> T[K, V]
Expand Down Expand Up @@ -72,6 +73,7 @@ impl T {
keys[K, V](Self[K, V]) -> Iter[K]
map[K : Eq + Hash, V, A](Self[K, V], (V) -> A) -> Self[K, A]
map_with_key[K : Eq + Hash, V, A](Self[K, V], (K, V) -> A) -> Self[K, A]
#deprecated
op_get[K : Eq + Hash, V](Self[K, V], K) -> V?
remove[K : Eq + Hash, V](Self[K, V], K) -> Self[K, V]
size[K, V](Self[K, V]) -> Int
Expand Down
2 changes: 2 additions & 0 deletions immut/sorted_map/sorted_map.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn new[K, V]() -> T[K, V]

fn of[K : Compare, V](FixedArray[(K, V)]) -> T[K, V]

#deprecated
fn op_get[K : Compare, V](T[K, V], K) -> V?

fn remove[K : Compare, V](T[K, V], K) -> T[K, V]
Expand Down Expand Up @@ -104,6 +105,7 @@ impl T {
new[K, V]() -> Self[K, V]
#deprecated
of[K : Compare, V](FixedArray[(K, V)]) -> Self[K, V]
#deprecated
op_get[K : Compare, V](Self[K, V], K) -> V?
remove[K : Compare, V](Self[K, V], K) -> Self[K, V]
#deprecated
Expand Down
1 change: 1 addition & 0 deletions immut/sorted_map/utils.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub fn get[K : Compare, V](self : T[K, V], key : K) -> V? {
}

///|
#deprecated("Use `get` instead. `op_get` will return `V` instead of `Option[V]` in the future.")
pub fn op_get[K : Compare, V](self : T[K, V], key : K) -> V? {
self.get(key)
}
Expand Down
2 changes: 1 addition & 1 deletion json/json.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn as_object(self : JsonValue) -> Map[String, JsonValue]? {
/// Try to get this element as a Json Object and get the element with the `key` as a Json Value
pub fn value(self : JsonValue, key : String) -> JsonValue? {
match self.as_object() {
Some(obj) => obj[key]
Some(obj) => obj.get(key)
None => None
}
}
Expand Down
1 change: 1 addition & 0 deletions sorted_map/map.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub fn op_set[K : Compare, V](self : T[K, V], key : K, value : V) -> Unit {
}

///|
#deprecated("Use `get` instead. `op_get` will return `V` instead of `Option[V]` in the future.")
pub fn op_get[K : Compare, V](self : T[K, V], key : K) -> V? {
self.get(key)
}
Expand Down
2 changes: 2 additions & 0 deletions sorted_map/sorted_map.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fn new[K, V]() -> T[K, V]
#deprecated
fn of[K : Compare, V](Array[(K, V)]) -> T[K, V]

#deprecated
fn op_get[K : Compare, V](T[K, V], K) -> V?

fn op_set[K : Compare, V](T[K, V], K, V) -> Unit
Expand Down Expand Up @@ -61,6 +62,7 @@ impl T {
iter[K, V](Self[K, V]) -> Iter[(K, V)]
iter2[K, V](Self[K, V]) -> Iter2[K, V]
keys[K, V](Self[K, V]) -> Array[K]
#deprecated
op_get[K : Compare, V](Self[K, V], K) -> V?
op_set[K : Compare, V](Self[K, V], K, V) -> Unit
range[K : Compare, V](Self[K, V], K, K) -> Iter2[K, V]
Expand Down