@@ -226,7 +226,7 @@ impl Type {
226226 /// This checks whether the argument `other` has attributes which are present
227227 /// in the given `Type`. This returns `true` on same arguments
228228 /// `a.is_subtype(a)` is `true`.
229- pub fn is_subtype ( & self , other : Self ) -> bool {
229+ pub const fn is_subtype ( & self , other : Self ) -> bool {
230230 self . corr . is_subtype ( other. corr ) && self . mall . is_subtype ( other. mall )
231231 }
232232
@@ -261,142 +261,209 @@ impl Type {
261261 pub const fn time ( ) -> Self { Type { corr : Correctness :: time ( ) , mall : Malleability :: time ( ) } }
262262
263263 /// Constructor for the type of the `a:` fragment.
264- pub fn cast_alt ( self ) -> Result < Self , ErrorKind > {
264+ pub const fn cast_alt ( self ) -> Result < Self , ErrorKind > {
265+ // FIXME need to do manual `?` because ? is not supported in constfns.
265266 Ok ( Type {
266- corr : Correctness :: cast_alt ( self . corr ) ?,
267+ corr : match Correctness :: cast_alt ( self . corr ) {
268+ Ok ( x) => x,
269+ Err ( e) => return Err ( e) ,
270+ } ,
267271 mall : Malleability :: cast_alt ( self . mall ) ,
268272 } )
269273 }
270274
271275 /// Constructor for the type of the `s:` fragment.
272- pub fn cast_swap ( self ) -> Result < Self , ErrorKind > {
276+ pub const fn cast_swap ( self ) -> Result < Self , ErrorKind > {
277+ // FIXME need to do manual `?` because ? is not supported in constfns.
273278 Ok ( Type {
274- corr : Correctness :: cast_swap ( self . corr ) ?,
279+ corr : match Correctness :: cast_swap ( self . corr ) {
280+ Ok ( x) => x,
281+ Err ( e) => return Err ( e) ,
282+ } ,
275283 mall : Malleability :: cast_swap ( self . mall ) ,
276284 } )
277285 }
278286
279287 /// Constructor for the type of the `c:` fragment.
280- pub fn cast_check ( self ) -> Result < Self , ErrorKind > {
288+ pub const fn cast_check ( self ) -> Result < Self , ErrorKind > {
281289 Ok ( Type {
282- corr : Correctness :: cast_check ( self . corr ) ?,
290+ corr : match Correctness :: cast_check ( self . corr ) {
291+ Ok ( x) => x,
292+ Err ( e) => return Err ( e) ,
293+ } ,
283294 mall : Malleability :: cast_check ( self . mall ) ,
284295 } )
285296 }
286297
287298 /// Constructor for the type of the `d:` fragment.
288- pub fn cast_dupif ( self ) -> Result < Self , ErrorKind > {
299+ pub const fn cast_dupif ( self ) -> Result < Self , ErrorKind > {
300+ // FIXME need to do manual `?` because ? is not supported in constfns.
289301 Ok ( Type {
290- corr : Correctness :: cast_dupif ( self . corr ) ?,
302+ corr : match Correctness :: cast_dupif ( self . corr ) {
303+ Ok ( x) => x,
304+ Err ( e) => return Err ( e) ,
305+ } ,
291306 mall : Malleability :: cast_dupif ( self . mall ) ,
292307 } )
293308 }
294309
295310 /// Constructor for the type of the `v:` fragment.
296- pub fn cast_verify ( self ) -> Result < Self , ErrorKind > {
311+ pub const fn cast_verify ( self ) -> Result < Self , ErrorKind > {
312+ // FIXME need to do manual `?` because ? is not supported in constfns.
297313 Ok ( Type {
298- corr : Correctness :: cast_verify ( self . corr ) ?,
314+ corr : match Correctness :: cast_verify ( self . corr ) {
315+ Ok ( x) => x,
316+ Err ( e) => return Err ( e) ,
317+ } ,
299318 mall : Malleability :: cast_verify ( self . mall ) ,
300319 } )
301320 }
302321
303322 /// Constructor for the type of the `j:` fragment.
304- pub fn cast_nonzero ( self ) -> Result < Self , ErrorKind > {
323+ pub const fn cast_nonzero ( self ) -> Result < Self , ErrorKind > {
324+ // FIXME need to do manual `?` because ? is not supported in constfns.
305325 Ok ( Type {
306- corr : Correctness :: cast_nonzero ( self . corr ) ?,
326+ corr : match Correctness :: cast_nonzero ( self . corr ) {
327+ Ok ( x) => x,
328+ Err ( e) => return Err ( e) ,
329+ } ,
307330 mall : Malleability :: cast_nonzero ( self . mall ) ,
308331 } )
309332 }
310333
311334 /// Constructor for the type of the `n:` fragment.
312- pub fn cast_zeronotequal ( self ) -> Result < Self , ErrorKind > {
335+ pub const fn cast_zeronotequal ( self ) -> Result < Self , ErrorKind > {
336+ // FIXME need to do manual `?` because ? is not supported in constfns.
313337 Ok ( Type {
314- corr : Correctness :: cast_zeronotequal ( self . corr ) ?,
338+ corr : match Correctness :: cast_zeronotequal ( self . corr ) {
339+ Ok ( x) => x,
340+ Err ( e) => return Err ( e) ,
341+ } ,
315342 mall : Malleability :: cast_zeronotequal ( self . mall ) ,
316343 } )
317344 }
318345
319346 /// Constructor for the type of the `t:` fragment.
320- pub fn cast_true ( self ) -> Result < Self , ErrorKind > {
347+ pub const fn cast_true ( self ) -> Result < Self , ErrorKind > {
348+ // FIXME need to do manual `?` because ? is not supported in constfns.
321349 Ok ( Type {
322- corr : Correctness :: cast_true ( self . corr ) ?,
350+ corr : match Correctness :: cast_true ( self . corr ) {
351+ Ok ( x) => x,
352+ Err ( e) => return Err ( e) ,
353+ } ,
323354 mall : Malleability :: cast_true ( self . mall ) ,
324355 } )
325356 }
326357
327358 /// Constructor for the type of the `u:` fragment.
328- pub fn cast_unlikely ( self ) -> Result < Self , ErrorKind > {
359+ pub const fn cast_unlikely ( self ) -> Result < Self , ErrorKind > {
360+ // FIXME need to do manual `?` because ? is not supported in constfns.
329361 Ok ( Type {
330- corr : Correctness :: cast_or_i_false ( self . corr ) ?,
362+ corr : match Correctness :: cast_or_i_false ( self . corr ) {
363+ Ok ( x) => x,
364+ Err ( e) => return Err ( e) ,
365+ } ,
331366 mall : Malleability :: cast_or_i_false ( self . mall ) ,
332367 } )
333368 }
334369
335370 /// Constructor for the type of the `l:` fragment.
336- pub fn cast_likely ( self ) -> Result < Self , ErrorKind > {
371+ pub const fn cast_likely ( self ) -> Result < Self , ErrorKind > {
372+ // FIXME need to do manual `?` because ? is not supported in constfns.
337373 Ok ( Type {
338- corr : Correctness :: cast_or_i_false ( self . corr ) ?,
374+ corr : match Correctness :: cast_or_i_false ( self . corr ) {
375+ Ok ( x) => x,
376+ Err ( e) => return Err ( e) ,
377+ } ,
339378 mall : Malleability :: cast_or_i_false ( self . mall ) ,
340379 } )
341380 }
342381
343382 /// Constructor for the type of the `and_b` fragment.
344- pub fn and_b ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
383+ pub const fn and_b ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
384+ // FIXME need to do manual `?` because ? is not supported in constfns.
345385 Ok ( Type {
346- corr : Correctness :: and_b ( left. corr , right. corr ) ?,
386+ corr : match Correctness :: and_b ( left. corr , right. corr ) {
387+ Ok ( x) => x,
388+ Err ( e) => return Err ( e) ,
389+ } ,
347390 mall : Malleability :: and_b ( left. mall , right. mall ) ,
348391 } )
349392 }
350393
351394 /// Constructor for the type of the `and_v` fragment.
352- pub fn and_v ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
395+ pub const fn and_v ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
396+ // FIXME need to do manual `?` because ? is not supported in constfns.
353397 Ok ( Type {
354- corr : Correctness :: and_v ( left. corr , right. corr ) ?,
398+ corr : match Correctness :: and_v ( left. corr , right. corr ) {
399+ Ok ( x) => x,
400+ Err ( e) => return Err ( e) ,
401+ } ,
355402 mall : Malleability :: and_v ( left. mall , right. mall ) ,
356403 } )
357404 }
358405
359406 /// Constructor for the type of the `or_b` fragment.
360- pub fn or_b ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
407+ pub const fn or_b ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
408+ // FIXME need to do manual `?` because ? is not supported in constfns.
361409 Ok ( Type {
362- corr : Correctness :: or_b ( left. corr , right. corr ) ?,
410+ corr : match Correctness :: or_b ( left. corr , right. corr ) {
411+ Ok ( x) => x,
412+ Err ( e) => return Err ( e) ,
413+ } ,
363414 mall : Malleability :: or_b ( left. mall , right. mall ) ,
364415 } )
365416 }
366417
367418 /// Constructor for the type of the `or_b` fragment.
368- pub fn or_d ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
419+ pub const fn or_d ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
420+ // FIXME need to do manual `?` because ? is not supported in constfns.
369421 Ok ( Type {
370- corr : Correctness :: or_d ( left. corr , right. corr ) ?,
422+ corr : match Correctness :: or_d ( left. corr , right. corr ) {
423+ Ok ( x) => x,
424+ Err ( e) => return Err ( e) ,
425+ } ,
371426 mall : Malleability :: or_d ( left. mall , right. mall ) ,
372427 } )
373428 }
374429
375430 /// Constructor for the type of the `or_c` fragment.
376- pub fn or_c ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
431+ pub const fn or_c ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
432+ // FIXME need to do manual `?` because ? is not supported in constfns.
377433 Ok ( Type {
378- corr : Correctness :: or_c ( left. corr , right. corr ) ?,
434+ corr : match Correctness :: or_c ( left. corr , right. corr ) {
435+ Ok ( x) => x,
436+ Err ( e) => return Err ( e) ,
437+ } ,
379438 mall : Malleability :: or_c ( left. mall , right. mall ) ,
380439 } )
381440 }
382441
383442 /// Constructor for the type of the `or_i` fragment.
384- pub fn or_i ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
443+ pub const fn or_i ( left : Self , right : Self ) -> Result < Self , ErrorKind > {
385444 Ok ( Type {
386- corr : Correctness :: or_i ( left. corr , right. corr ) ?,
445+ corr : match Correctness :: or_i ( left. corr , right. corr ) {
446+ Ok ( x) => x,
447+ Err ( e) => return Err ( e) ,
448+ } ,
387449 mall : Malleability :: or_i ( left. mall , right. mall ) ,
388450 } )
389451 }
390452
391453 /// Constructor for the type of the `and_or` fragment.
392- pub fn and_or ( a : Self , b : Self , c : Self ) -> Result < Self , ErrorKind > {
454+ pub const fn and_or ( a : Self , b : Self , c : Self ) -> Result < Self , ErrorKind > {
455+ // FIXME need to do manual `?` because ? is not supported in constfns.
393456 Ok ( Type {
394- corr : Correctness :: and_or ( a. corr , b. corr , c. corr ) ?,
457+ corr : match Correctness :: and_or ( a. corr , b. corr , c. corr ) {
458+ Ok ( x) => x,
459+ Err ( e) => return Err ( e) ,
460+ } ,
395461 mall : Malleability :: and_or ( a. mall , b. mall , c. mall ) ,
396462 } )
397463 }
398464
399465 /// Constructor for the type of the `thresh` fragment.
466+ // Cannot be a constfn because it takes a closure.
400467 pub fn threshold < S > ( k : usize , n : usize , mut sub_ck : S ) -> Result < Self , ErrorKind >
401468 where
402469 S : FnMut ( usize ) -> Result < Self , ErrorKind > ,
0 commit comments