@@ -4,7 +4,7 @@ use core::cmp::Ordering;
4
4
5
5
use crate as rune;
6
6
use crate :: runtime:: {
7
- ControlFlow , EnvProtocolCaller , Function , Generator , GeneratorState , Iterator , Protocol , Range ,
7
+ ControlFlow , EnvProtocolCaller , Function , Generator , GeneratorState , Iterator , Range ,
8
8
RangeFrom , RangeFull , RangeInclusive , RangeTo , RangeToInclusive , Value , Vm , VmResult ,
9
9
} ;
10
10
use crate :: { ContextError , Module } ;
@@ -16,44 +16,6 @@ pub fn module() -> Result<Module, ContextError> {
16
16
17
17
{
18
18
m. ty :: < RangeFrom > ( ) ?;
19
- m. type_meta :: < RangeFrom > ( ) ?
20
- . make_named_struct ( & [ "start" ] ) ?
21
- . docs ( [
22
- "Type for a from range expression `start..`." ,
23
- "" ,
24
- "# Examples" ,
25
- "" ,
26
- "```rune" ,
27
- "let range = 0..;" ,
28
- "" ,
29
- "assert!(!range.contains(-10));" ,
30
- "assert!(range.contains(5));" ,
31
- "assert!(range.contains(10));" ,
32
- "assert!(range.contains(20));" ,
33
- "" ,
34
- "assert!(range is std::ops::RangeFrom);" ,
35
- "```" ,
36
- "" ,
37
- "Ranges can contain any type:" ,
38
- "" ,
39
- "```rune" ,
40
- "let range = 'a'..;" ,
41
- "assert_eq!(range.start, 'a');" ,
42
- "range.start = 'b';" ,
43
- "assert_eq!(range.start, 'b');" ,
44
- "```" ,
45
- "" ,
46
- "Certain ranges can be used as iterators:" ,
47
- "" ,
48
- "```rune" ,
49
- "let range = 'a'..;" ,
50
- "assert_eq!(range.iter().take(5).collect::<Vec>(), ['a', 'b', 'c', 'd', 'e']);" ,
51
- "```" ,
52
- ] ) ;
53
- m. field_function ( Protocol :: GET , "start" , |r : & RangeFrom | r. start . clone ( ) ) ?;
54
- m. field_function ( Protocol :: SET , "start" , |r : & mut RangeFrom , value : Value | {
55
- r. start = value;
56
- } ) ?;
57
19
m. function_meta ( RangeFrom :: iter__meta) ?;
58
20
m. function_meta ( RangeFrom :: contains__meta) ?;
59
21
m. function_meta ( RangeFrom :: into_iter__meta) ?;
@@ -65,80 +27,11 @@ pub fn module() -> Result<Module, ContextError> {
65
27
66
28
{
67
29
m. ty :: < RangeFull > ( ) ?;
68
- m. type_meta :: < RangeFull > ( ) ?. make_empty_struct ( ) ?. docs ( [
69
- "Type for a full range expression `..`." ,
70
- "" ,
71
- "# Examples" ,
72
- "" ,
73
- "```rune" ,
74
- "let range = ..;" ,
75
- "" ,
76
- "assert!(range.contains(-10));" ,
77
- "assert!(range.contains(5));" ,
78
- "assert!(range.contains(10));" ,
79
- "assert!(range.contains(20));" ,
80
- "" ,
81
- "assert!(range is std::ops::RangeFull);" ,
82
- "```" ,
83
- ] ) ;
84
30
m. function_meta ( RangeFull :: contains) ?;
85
31
}
86
32
87
33
{
88
34
m. ty :: < RangeInclusive > ( ) ?;
89
- m. type_meta :: < RangeInclusive > ( ) ?
90
- . make_named_struct ( & [ "start" , "end" ] ) ?
91
- . docs ( [
92
- "Type for an inclusive range expression `start..=end`." ,
93
- "" ,
94
- "# Examples" ,
95
- "" ,
96
- "```rune" ,
97
- "let range = 0..=10;" ,
98
- "" ,
99
- "assert!(!range.contains(-10));" ,
100
- "assert!(range.contains(5));" ,
101
- "assert!(range.contains(10));" ,
102
- "assert!(!range.contains(20));" ,
103
- "" ,
104
- "assert!(range is std::ops::RangeInclusive);" ,
105
- "```" ,
106
- "" ,
107
- "Ranges can contain any type:" ,
108
- "" ,
109
- "```rune" ,
110
- "let range = 'a'..='f';" ,
111
- "assert_eq!(range.start, 'a');" ,
112
- "range.start = 'b';" ,
113
- "assert_eq!(range.start, 'b');" ,
114
- "assert_eq!(range.end, 'f');" ,
115
- "range.end = 'g';" ,
116
- "assert_eq!(range.end, 'g');" ,
117
- "```" ,
118
- "" ,
119
- "Certain ranges can be used as iterators:" ,
120
- "" ,
121
- "```rune" ,
122
- "let range = 'a'..='e';" ,
123
- "assert_eq!(range.iter().collect::<Vec>(), ['a', 'b', 'c', 'd', 'e']);" ,
124
- "```" ,
125
- ] ) ;
126
- m. field_function ( Protocol :: GET , "start" , |r : & RangeInclusive | r. start . clone ( ) ) ?;
127
- m. field_function (
128
- Protocol :: SET ,
129
- "start" ,
130
- |r : & mut RangeInclusive , value : Value | {
131
- r. start = value;
132
- } ,
133
- ) ?;
134
- m. field_function ( Protocol :: GET , "end" , |r : & RangeInclusive | r. end . clone ( ) ) ?;
135
- m. field_function (
136
- Protocol :: SET ,
137
- "end" ,
138
- |r : & mut RangeInclusive , value : Value | {
139
- r. end = value;
140
- } ,
141
- ) ?;
142
35
m. function_meta ( RangeInclusive :: iter__meta) ?;
143
36
m. function_meta ( RangeInclusive :: contains__meta) ?;
144
37
m. function_meta ( RangeInclusive :: into_iter__meta) ?;
@@ -150,40 +43,6 @@ pub fn module() -> Result<Module, ContextError> {
150
43
151
44
{
152
45
m. ty :: < RangeToInclusive > ( ) ?;
153
- m. type_meta :: < RangeToInclusive > ( ) ?
154
- . make_named_struct ( & [ "end" ] ) ?
155
- . docs ( [
156
- "Type for an inclusive range expression `..=end`." ,
157
- "" ,
158
- "# Examples" ,
159
- "" ,
160
- "```rune" ,
161
- "let range = ..=10;" ,
162
- "assert!(range.contains(-10));" ,
163
- "assert!(range.contains(5));" ,
164
- "assert!(range.contains(10));" ,
165
- "assert!(!range.contains(20));" ,
166
- "" ,
167
- "assert!(range is std::ops::RangeToInclusive);" ,
168
- "```" ,
169
- "" ,
170
- "Ranges can contain any type:" ,
171
- "" ,
172
- "```rune" ,
173
- "let range = ..='f';" ,
174
- "assert_eq!(range.end, 'f');" ,
175
- "range.end = 'g';" ,
176
- "assert_eq!(range.end, 'g');" ,
177
- "```" ,
178
- ] ) ;
179
- m. field_function ( Protocol :: GET , "end" , |r : & RangeToInclusive | r. end . clone ( ) ) ?;
180
- m. field_function (
181
- Protocol :: SET ,
182
- "end" ,
183
- |r : & mut RangeToInclusive , value : Value | {
184
- r. end = value;
185
- } ,
186
- ) ?;
187
46
m. function_meta ( RangeToInclusive :: contains__meta) ?;
188
47
m. function_meta ( RangeToInclusive :: partial_eq__meta) ?;
189
48
m. function_meta ( RangeToInclusive :: eq__meta) ?;
@@ -193,36 +52,6 @@ pub fn module() -> Result<Module, ContextError> {
193
52
194
53
{
195
54
m. ty :: < RangeTo > ( ) ?;
196
- m. type_meta :: < RangeTo > ( ) ?
197
- . make_named_struct ( & [ "end" ] ) ?
198
- . docs ( [
199
- "Type for an inclusive range expression `..end`." ,
200
- "" ,
201
- "# Examples" ,
202
- "" ,
203
- "```rune" ,
204
- "let range = ..10;" ,
205
- "assert!(range.contains(-10));" ,
206
- "assert!(range.contains(5));" ,
207
- "assert!(!range.contains(10));" ,
208
- "assert!(!range.contains(20));" ,
209
- "" ,
210
- "assert!(range is std::ops::RangeTo);" ,
211
- "```" ,
212
- "" ,
213
- "Ranges can contain any type:" ,
214
- "" ,
215
- "```rune" ,
216
- "let range = ..'f';" ,
217
- "assert_eq!(range.end, 'f');" ,
218
- "range.end = 'g';" ,
219
- "assert_eq!(range.end, 'g');" ,
220
- "```" ,
221
- ] ) ;
222
- m. field_function ( Protocol :: GET , "end" , |r : & RangeTo | r. end . clone ( ) ) ?;
223
- m. field_function ( Protocol :: SET , "end" , |r : & mut RangeTo , value : Value | {
224
- r. end = value;
225
- } ) ?;
226
55
m. function_meta ( RangeTo :: contains__meta) ?;
227
56
m. function_meta ( RangeTo :: partial_eq__meta) ?;
228
57
m. function_meta ( RangeTo :: eq__meta) ?;
@@ -232,50 +61,6 @@ pub fn module() -> Result<Module, ContextError> {
232
61
233
62
{
234
63
m. ty :: < Range > ( ) ?;
235
- m. type_meta :: < Range > ( ) ?
236
- . make_named_struct ( & [ "start" , "end" ] ) ?
237
- . docs ( [
238
- "Type for a range expression `start..end`." ,
239
- "" ,
240
- "# Examples" ,
241
- "" ,
242
- "```rune" ,
243
- "let range = 0..10;" ,
244
- "assert!(!range.contains(-10));" ,
245
- "assert!(range.contains(5));" ,
246
- "assert!(!range.contains(10));" ,
247
- "assert!(!range.contains(20));" ,
248
- "" ,
249
- "assert!(range is std::ops::Range);" ,
250
- "```" ,
251
- "" ,
252
- "Ranges can contain any type:" ,
253
- "" ,
254
- "```rune" ,
255
- "let range = 'a'..'f';" ,
256
- "assert_eq!(range.start, 'a');" ,
257
- "range.start = 'b';" ,
258
- "assert_eq!(range.start, 'b');" ,
259
- "assert_eq!(range.end, 'f');" ,
260
- "range.end = 'g';" ,
261
- "assert_eq!(range.end, 'g');" ,
262
- "```" ,
263
- "" ,
264
- "Certain ranges can be used as iterators:" ,
265
- "" ,
266
- "```rune" ,
267
- "let range = 'a'..'e';" ,
268
- "assert_eq!(range.iter().collect::<Vec>(), ['a', 'b', 'c', 'd']);" ,
269
- "```" ,
270
- ] ) ;
271
- m. field_function ( Protocol :: GET , "start" , |r : & Range | r. start . clone ( ) ) ?;
272
- m. field_function ( Protocol :: SET , "start" , |r : & mut Range , value : Value | {
273
- r. start = value;
274
- } ) ?;
275
- m. field_function ( Protocol :: GET , "end" , |r : & Range | r. end . clone ( ) ) ?;
276
- m. field_function ( Protocol :: SET , "end" , |r : & mut Range , value : Value | {
277
- r. end = value;
278
- } ) ?;
279
64
m. function_meta ( Range :: iter__meta) ?;
280
65
m. function_meta ( Range :: into_iter__meta) ?;
281
66
m. function_meta ( Range :: contains__meta) ?;
@@ -286,51 +71,10 @@ pub fn module() -> Result<Module, ContextError> {
286
71
}
287
72
288
73
{
289
- m. ty :: < ControlFlow > ( ) ?. docs ( [
290
- " Used to tell an operation whether it should exit early or go on as usual." ,
291
- "" ,
292
- " This acts as the basis of the [`TRY`] protocol in Rune." ,
293
- "" ,
294
- " [`TRY`]: crate::Protocol::TRY" ,
295
- "" ,
296
- "# Examples" ,
297
- "" ,
298
- "```rune" ,
299
- "use std::ops::ControlFlow;" ,
300
- "" ,
301
- "let c = ControlFlow::Continue(42);" ,
302
- "assert_eq!(c.0, 42);" ,
303
- "assert_eq!(c, ControlFlow::Continue(42));" ,
304
- "```" ,
305
- ] ) ;
74
+ m. ty :: < ControlFlow > ( ) ?;
306
75
}
307
76
308
- m. ty :: < Function > ( ) ?. docs ( [
309
- "The type of a function in Rune." ,
310
- "" ,
311
- "Functions can be called using call expression syntax, such as `<expr>()`." ,
312
- "" ,
313
- "There are multiple different kind of things which can be coerced into a function in Rune:" ,
314
- "* Regular functions." ,
315
- "* Closures (which might or might not capture their environment)." ,
316
- "* Built-in constructors for tuple types (tuple structs, tuple variants)." ,
317
- "" ,
318
- "# Examples" ,
319
- "" ,
320
- "```rune" ,
321
- "// Captures the constructor for the `Some(<value>)` tuple variant." ,
322
- "let build_some = Some;" ,
323
- "assert_eq!(build_some(42), Some(42));" ,
324
- "" ,
325
- "fn build(value) {" ,
326
- " Some(value)" ,
327
- "}" ,
328
- "" ,
329
- "// Captures the function previously defined." ,
330
- "let build_some = build;" ,
331
- "assert_eq!(build_some(42), Some(42));" ,
332
- "```" ,
333
- ] ) ;
77
+ m. ty :: < Function > ( ) ?;
334
78
335
79
{
336
80
m. ty :: < Generator < Vm > > ( ) ?. docs ( [
0 commit comments