Skip to content

Commit

Permalink
move deprecated definitions to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
Guest0x0 committed Jan 14, 2025
1 parent fa7db8d commit f7d3931
Show file tree
Hide file tree
Showing 32 changed files with 587 additions and 291 deletions.
5 changes: 0 additions & 5 deletions buffer/buffer.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@ pub fn new(size_hint~ : Int = 0) -> T {
{ data, len: 0, initial_data: data }
}

///| @alert deprecated "use `@buffer.new` instead"
pub fn T::new(size_hint~ : Int = 0) -> T {
new(size_hint~)
}

///|
/// Writes a UTF-16LE encoded string into the buffer. The buffer will
/// automatically grow if needed to accommodate the string.
Expand Down
7 changes: 7 additions & 0 deletions buffer/deprecated.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@ pub fn write_sub_string(
) -> Unit {
self.write_substring(value, start, len)
}

///|
/// @alert deprecated "use `@buffer.new` instead"
/// @coverage.skip
pub fn T::new(size_hint~ : Int = 0) -> T {
new(size_hint~)
}
41 changes: 41 additions & 0 deletions deque/deprecated.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2025 International Digital Economy Academy
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

///|
/// @alert deprecated "use `@deque.new` instead"
/// @coverage.skip
pub fn T::new[A](capacity~ : Int = 0) -> T[A] {
new(capacity~)
}

///|
/// @alert deprecated "use `@deque.from_array` instead"
/// @coverage.skip
pub fn T::from_array[A](arr : Array[A]) -> T[A] {
from_array(arr)
}

///|
/// @alert deprecated "use `@deque.of` instead"
/// @coverage.skip
pub fn T::of[A](arr : FixedArray[A]) -> T[A] {
of(arr)
}

///|
/// @alert deprecated "use `@deque.from_iter` instead"
/// @coverage.skip
pub fn T::from_iter[A](iter : Iter[A]) -> T[A] {
from_iter(iter)
}
20 changes: 0 additions & 20 deletions deque/deque.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ pub fn new[A](capacity~ : Int = 0) -> T[A] {
T::{ buf: UninitializedArray::make(capacity), len: 0, head: 0, tail: 0 }
}

///| @alert deprecated "use `@deque.new` instead"
pub fn T::new[A](capacity~ : Int = 0) -> T[A] {
new(capacity~)
}

///|
pub impl[A : Show] Show for T[A] with output(self, logger) {
logger.write_iter(self.iter(), prefix="@deque.of([", suffix="])")
Expand Down Expand Up @@ -87,11 +82,6 @@ pub fn from_array[A](arr : Array[A]) -> T[A] {
deq
}

///| @alert deprecated "use `@deque.from_array` instead"
pub fn T::from_array[A](arr : Array[A]) -> T[A] {
from_array(arr)
}

///|
/// Creates a new deque with the same elements as the original deque. The new
/// deque will have a capacity equal to its length, and its elements will be
Expand Down Expand Up @@ -157,11 +147,6 @@ pub fn of[A](arr : FixedArray[A]) -> T[A] {
deq
}

///| @alert deprecated "use `@deque.of` instead"
pub fn T::of[A](arr : FixedArray[A]) -> T[A] {
of(arr)
}

///|
/// Returns the number of elements in the deque.
///
Expand Down Expand Up @@ -1259,8 +1244,3 @@ pub fn from_iter[A](iter : Iter[A]) -> T[A] {
iter.each(fn(e) { dq.push_back(e) })
dq
}

///| @alert deprecated "use `@deque.from_iter` instead"
pub fn T::from_iter[A](iter : Iter[A]) -> T[A] {
from_iter(iter)
}
34 changes: 34 additions & 0 deletions hashmap/deprecated.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2025 International Digital Economy Academy
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

///|
/// @alert deprecated "use `@hashmap.new` instead"
/// @coverage.skip
pub fn T::new[K, V](capacity~ : Int = 8) -> T[K, V] {
new(capacity~)
}

///|
/// @alert deprecated "use `@hashmap.from_array` instead"
/// @coverage.skip
pub fn T::from_array[K : Hash + Eq, V](arr : Array[(K, V)]) -> T[K, V] {
from_array(arr)
}

///|
/// @alert deprecated "use `@hashmap.of` instead"
/// @coverage.skip
pub fn T::of[K : Eq + Hash, V](arr : FixedArray[(K, V)]) -> T[K, V] {
of(arr)
}
15 changes: 0 additions & 15 deletions hashmap/hashmap.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ pub fn new[K, V](capacity~ : Int = 8) -> T[K, V] {
{ size: 0, capacity, entries: FixedArray::make(capacity, None) }
}

///| @alert deprecated "use `@hashmap.new` instead"
pub fn T::new[K, V](capacity~ : Int = 8) -> T[K, V] {
new(capacity~)
}

///|
/// Create new hash map from array.
pub fn from_array[K : Hash + Eq, V](arr : Array[(K, V)]) -> T[K, V] {
Expand All @@ -56,11 +51,6 @@ pub fn from_array[K : Hash + Eq, V](arr : Array[(K, V)]) -> T[K, V] {
m
}

///| @alert deprecated "use `@hashmap.from_array` instead"
pub fn T::from_array[K : Hash + Eq, V](arr : Array[(K, V)]) -> T[K, V] {
from_array(arr)
}

///|
/// Set a key-value pair into hash map.
/// @alert unsafe "Panic if the hash map is full."
Expand Down Expand Up @@ -263,11 +253,6 @@ pub fn of[K : Eq + Hash, V](arr : FixedArray[(K, V)]) -> T[K, V] {
m
}

///| @alert deprecated "use `@hashmap.of` instead"
pub fn T::of[K : Eq + Hash, V](arr : FixedArray[(K, V)]) -> T[K, V] {
of(arr)
}

test "of" {
let m = of([(1, 2), (3, 4)])
inspect!(m.get(1), content="Some(2)")
Expand Down
41 changes: 41 additions & 0 deletions hashset/deprecated.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2025 International Digital Economy Academy
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

///|
/// @alert deprecated "use `@hashset.new` instead"
/// @coverage.skip
pub fn T::new[K](capacity~ : Int = default_init_capacity) -> T[K] {
new(capacity~)
}

///|
/// @alert deprecated "use `@hashset.from_array` instead"
/// @coverage.skip
pub fn T::from_array[K : Hash + Eq](arr : Array[K]) -> T[K] {
from_array(arr)
}

///|
/// @alert deprecated "use `@hashset.of` instead"
/// @coverage.skip
pub fn T::of[K : Hash + Eq](arr : FixedArray[K]) -> T[K] {
of(arr)
}

///|
/// @alert deprecated "use `@hashset.from_iter` instead"
/// @coverage.skip
pub fn T::from_iter[K : Hash + Eq](iter : Iter[K]) -> T[K] {
from_iter(iter)
}
20 changes: 0 additions & 20 deletions hashset/hashset.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ pub fn new[K](capacity~ : Int = default_init_capacity) -> T[K] {
}
}

///| @alert deprecated "use `@hashset.new` instead"
pub fn T::new[K](capacity~ : Int = default_init_capacity) -> T[K] {
new(capacity~)
}

///|
/// Create new hash set from array.
pub fn from_array[K : Hash + Eq](arr : Array[K]) -> T[K] {
Expand All @@ -40,23 +35,13 @@ pub fn from_array[K : Hash + Eq](arr : Array[K]) -> T[K] {
m
}

///| @alert deprecated "use `@hashset.from_array` instead"
pub fn T::from_array[K : Hash + Eq](arr : Array[K]) -> T[K] {
from_array(arr)
}

///|
pub fn of[K : Hash + Eq](arr : FixedArray[K]) -> T[K] {
let m = new()
arr.each(fn(e) { m.add(e) })
m
}

///| @alert deprecated "use `@hashset.of` instead"
pub fn T::of[K : Hash + Eq](arr : FixedArray[K]) -> T[K] {
of(arr)
}

///|
/// Insert a key into hash set.
/// @alert unsafe "Panic if the hash set is full."
Expand Down Expand Up @@ -253,11 +238,6 @@ pub fn from_iter[K : Hash + Eq](iter : Iter[K]) -> T[K] {
s
}

///| @alert deprecated "use `@hashset.from_iter` instead"
pub fn T::from_iter[K : Hash + Eq](iter : Iter[K]) -> T[K] {
from_iter(iter)
}

///|
pub impl[X : @quickcheck.Arbitrary + Eq + Hash] @quickcheck.Arbitrary for T[X] with arbitrary(
size,
Expand Down
30 changes: 0 additions & 30 deletions immut/array/array.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ pub fn new[A]() -> T[A] {
{ tree: Tree::empty(), size: 0, shift: 0 }
}

///| @alert deprecated "use `@immut/array.new` instead"
pub fn T::new[A]() -> T[A] {
new()
}

///|
pub impl[A : Show] Show for T[A] with output(self, logger) {
logger.write_iter(self.iter(), prefix="@immut/array.of([", suffix="])")
Expand Down Expand Up @@ -59,11 +54,6 @@ pub fn from_iter[A](iter : Iter[A]) -> T[A] {
iter.fold(init=new(), fn(arr, e) { arr.push(e) })
}

///| @alert deprecated "use `@immut/array.from_iter` instead"
pub fn T::from_iter[A](iter : Iter[A]) -> T[A] {
from_iter(iter)
}

///|
pub fn length[A](self : T[A]) -> Int {
self.size
Expand Down Expand Up @@ -164,11 +154,6 @@ pub fn from_array[A](arr : Array[A]) -> T[A] {
makei(arr.length(), fn(i) { arr[i] })
}

///| @alert deprecated "use `@immut/array.from_array` instead"
pub fn T::from_array[A](arr : Array[A]) -> T[A] {
from_array(arr)
}

///|
/// Iterate over the array.
///
Expand Down Expand Up @@ -375,32 +360,17 @@ pub fn make[A](len : Int, value : A) -> T[A] {
new_by_leaves(len, fn(_s, l) { FixedArray::make(l, value) })
}

///| @alert deprecated "use `@immut/array.make` instead"
pub fn T::make[A](len : Int, value : A) -> T[A] {
make(len, value)
}

///|
/// Create a persistent array with a given length and a function to generate values.
pub fn makei[A](len : Int, f : (Int) -> A) -> T[A] {
new_by_leaves(len, fn(s, l) { FixedArray::makei(l, fn(i) { f(s + i) }) })
}

///| @alert deprecated "use `@immut/array.makei` instead"
pub fn T::makei[A](len : Int, f : (Int) -> A) -> T[A] {
makei(len, f)
}

///|
pub fn of[A](arr : FixedArray[A]) -> T[A] {
makei(arr.length(), fn(i) { arr[i] })
}

///| @alert deprecated "use `@immut/array.of` instead"
pub fn T::of[A](arr : FixedArray[A]) -> T[A] {
of(arr)
}

///|
pub impl[X : @quickcheck.Arbitrary] @quickcheck.Arbitrary for T[X] with arbitrary(
size,
Expand Down
55 changes: 55 additions & 0 deletions immut/array/deprecated.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2025 International Digital Economy Academy
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

///|
/// @alert deprecated "use `@immut/array.new` instead"
/// @coverage.skip
pub fn T::new[A]() -> T[A] {
new()
}

///|
/// @alert deprecated "use `@immut/array.from_iter` instead"
/// @coverage.skip
pub fn T::from_iter[A](iter : Iter[A]) -> T[A] {
from_iter(iter)
}

///|
/// @alert deprecated "use `@immut/array.from_array` instead"
/// @coverage.skip
pub fn T::from_array[A](arr : Array[A]) -> T[A] {
from_array(arr)
}

///|
/// @alert deprecated "use `@immut/array.make` instead"
/// @coverage.skip
pub fn T::make[A](len : Int, value : A) -> T[A] {
make(len, value)
}

///|
/// @alert deprecated "use `@immut/array.makei` instead"
/// @coverage.skip
pub fn T::makei[A](len : Int, f : (Int) -> A) -> T[A] {
makei(len, f)
}

///|
/// @alert deprecated "use `@immut/array.of` instead"
/// @coverage.skip
pub fn T::of[A](arr : FixedArray[A]) -> T[A] {
of(arr)
}
Loading

0 comments on commit f7d3931

Please sign in to comment.