@@ -22,15 +22,36 @@ use super::{array_type, array_type_def, ARRAY_TYPENAME};
22
22
23
23
/// Array operation definitions.
24
24
#[ derive( Clone , Copy , Debug , Hash , PartialEq , Eq , EnumIter , IntoStaticStr , EnumString ) ]
25
- #[ allow( non_camel_case_types, missing_docs ) ]
25
+ #[ allow( non_camel_case_types) ]
26
26
#[ non_exhaustive]
27
27
pub enum ArrayOpDef {
28
+ /// Makes a new array, given distinct inputs equal to its length:
29
+ /// `new_array<SIZE><elemty>: (elemty)^SIZE -> array<SIZE, elemty>`
30
+ /// where `SIZE` must be statically known (not a variable)
28
31
new_array,
32
+ /// Copies an element out of the array ([TypeBound::Copyable] elements only):
33
+ /// `get<size,elemty>: array<size, elemty>, index -> option<elemty>`
29
34
get,
35
+ /// Exchanges an element of the array with an external value:
36
+ /// `set<size, elemty>: array<size, elemty>, index, elemty -> either(elemty, array | elemty, array)`
37
+ /// tagged for failure/success respectively
30
38
set,
39
+ /// Exchanges the elements at two indices within the array:
40
+ /// `swap<size, elemty>: array<size, elemty>, index, index -> either(array, array)`
41
+ /// tagged for failure/success respectively
31
42
swap,
43
+ /// Separates the leftmost element from the rest of the array:
44
+ /// `pop_left<SIZE><elemty>: array<SIZE, elemty> -> Option<elemty, array<SIZE-1, elemty>>`
45
+ /// where `SIZE` must be known statically (not a variable).
46
+ /// `None` is returned if the input array was size 0.
32
47
pop_left,
48
+ /// Separates the rightmost element from the rest of the array.
49
+ /// `pop_right<SIZE><elemty>: array<SIZE, elemty> -> Option<elemty, array<SIZE-1, elemty>>`
50
+ /// where `SIZE` must be known statically (not a variable).
51
+ /// `None` is returned if the input array was size 0.
33
52
pop_right,
53
+ /// Allows discarding a 0-element array of linear type.
54
+ /// `discard_empty<elemty>: array<0, elemty> -> ` (no outputs)
34
55
discard_empty,
35
56
}
36
57
0 commit comments