@@ -371,35 +371,18 @@ pub struct DebruijnIndex {
371
371
depth : u32 ,
372
372
}
373
373
374
- impl From < u32 > for DebruijnIndex {
375
- fn from ( depth : u32 ) -> Self {
376
- Self :: from_u32 ( depth)
377
- }
378
- }
379
-
380
- impl From < usize > for DebruijnIndex {
381
- fn from ( depth : usize ) -> Self {
382
- assert ! ( depth < ( std:: u32 :: MAX as usize ) ) ;
383
- Self :: from_u32 ( depth as u32 )
384
- }
385
- }
386
-
387
374
impl DebruijnIndex {
388
375
pub const INNERMOST : DebruijnIndex = DebruijnIndex { depth : 0 } ;
389
376
pub const ONE : DebruijnIndex = DebruijnIndex { depth : 1 } ;
390
377
391
- pub fn from_u32 ( depth : u32 ) -> Self {
378
+ pub fn new ( depth : u32 ) -> Self {
392
379
DebruijnIndex { depth }
393
380
}
394
381
395
- pub fn as_u32 ( self ) -> u32 {
382
+ pub fn depth ( self ) -> u32 {
396
383
self . depth
397
384
}
398
385
399
- pub fn as_usize ( self ) -> usize {
400
- self . depth as usize
401
- }
402
-
403
386
/// True if the binder identified by this index is within the
404
387
/// binder identified by the index `outer_binder`.
405
388
///
@@ -463,7 +446,7 @@ impl DebruijnIndex {
463
446
/// innermost binder, has index 3).
464
447
#[ must_use]
465
448
pub fn shifted_in_from ( self , outer_binder : DebruijnIndex ) -> DebruijnIndex {
466
- DebruijnIndex :: from ( self . as_usize ( ) + outer_binder. as_usize ( ) )
449
+ DebruijnIndex :: new ( self . depth ( ) + outer_binder. depth ( ) )
467
450
}
468
451
469
452
/// Returns the resulting index when this value is moved out from
@@ -508,9 +491,7 @@ impl DebruijnIndex {
508
491
if self . within ( outer_binder) {
509
492
None
510
493
} else {
511
- Some ( DebruijnIndex :: from (
512
- self . as_usize ( ) - outer_binder. as_usize ( ) ,
513
- ) )
494
+ Some ( DebruijnIndex :: new ( self . depth ( ) - outer_binder. depth ( ) ) )
514
495
}
515
496
}
516
497
}
0 commit comments