@@ -410,18 +410,21 @@ impl PartialEq<CrateRootModuleId> for ModuleId {
410
410
}
411
411
412
412
impl From < CrateRootModuleId > for ModuleId {
413
+ /// Make a `ModuleId` with a krate, no block, and local_id of `ROOT`
413
414
fn from ( CrateRootModuleId { krate } : CrateRootModuleId ) -> Self {
414
415
ModuleId { krate, block : None , local_id : DefMap :: ROOT }
415
416
}
416
417
}
417
418
418
419
impl From < CrateRootModuleId > for ModuleDefId {
420
+ /// Make a `ModuleId` with `CrateRootModuleId` as inner
419
421
fn from ( value : CrateRootModuleId ) -> Self {
420
422
ModuleDefId :: ModuleId ( value. into ( ) )
421
423
}
422
424
}
423
425
424
426
impl From < CrateId > for CrateRootModuleId {
427
+ /// Create a `CrateRootModuleId` with `CrateId` as inner
425
428
fn from ( krate : CrateId ) -> Self {
426
429
CrateRootModuleId { krate }
427
430
}
@@ -564,6 +567,7 @@ impl TypeParamId {
564
567
}
565
568
566
569
impl From < TypeParamId > for TypeOrConstParamId {
570
+ /// Get the inner `TypeOrConstParamId` of `TypeParamId`
567
571
fn from ( it : TypeParamId ) -> Self {
568
572
it. 0
569
573
}
@@ -590,6 +594,7 @@ impl ConstParamId {
590
594
}
591
595
592
596
impl From < ConstParamId > for TypeOrConstParamId {
597
+ /// Get the inner `TypeOrConstParamId` of `ConstParamId`
593
598
fn from ( it : ConstParamId ) -> Self {
594
599
it. 0
595
600
}
@@ -729,6 +734,7 @@ impl_from!(
729
734
730
735
// Every `DefWithBodyId` is a type owner, since bodies can contain type (e.g. `{ let it: Type = _; }`)
731
736
impl From < DefWithBodyId > for TypeOwnerId {
737
+ /// Convert `DefWithBodyId` inner into `TypeOwnerId`
732
738
fn from ( value : DefWithBodyId ) -> Self {
733
739
match value {
734
740
DefWithBodyId :: FunctionId ( it) => it. into ( ) ,
@@ -741,6 +747,7 @@ impl From<DefWithBodyId> for TypeOwnerId {
741
747
}
742
748
743
749
impl From < GenericDefId > for TypeOwnerId {
750
+ /// Convert `GenericDefId` inner into `TypeOwnerId`
744
751
fn from ( value : GenericDefId ) -> Self {
745
752
match value {
746
753
GenericDefId :: FunctionId ( it) => it. into ( ) ,
@@ -896,6 +903,7 @@ pub enum DefWithBodyId {
896
903
impl_from ! ( FunctionId , ConstId , StaticId , InTypeConstId for DefWithBodyId ) ;
897
904
898
905
impl From < EnumVariantId > for DefWithBodyId {
906
+ /// Make a `VariantId` with `EnumVariantId`, as inner
899
907
fn from ( id : EnumVariantId ) -> Self {
900
908
DefWithBodyId :: VariantId ( id)
901
909
}
@@ -1008,6 +1016,7 @@ impl GenericDefId {
1008
1016
}
1009
1017
1010
1018
impl From < AssocItemId > for GenericDefId {
1019
+ /// Convert `AssocItemId` inner to `GenericDefId`
1011
1020
fn from ( item : AssocItemId ) -> Self {
1012
1021
match item {
1013
1022
AssocItemId :: FunctionId ( f) => f. into ( ) ,
@@ -1028,6 +1037,7 @@ impl InternValueTrivial for CallableDefId {}
1028
1037
1029
1038
impl_from ! ( FunctionId , StructId , EnumVariantId for CallableDefId ) ;
1030
1039
impl From < CallableDefId > for ModuleDefId {
1040
+ /// Match `CallableDefId` to `ModuleDefId`
1031
1041
fn from ( def : CallableDefId ) -> ModuleDefId {
1032
1042
match def {
1033
1043
CallableDefId :: FunctionId ( f) => ModuleDefId :: FunctionId ( f) ,
@@ -1089,6 +1099,10 @@ impl_from!(
1089
1099
impl TryFrom < ModuleDefId > for AttrDefId {
1090
1100
type Error = ( ) ;
1091
1101
1102
+ /// Convert the inner of `ModuleDefId` into `Ok(AttrDefId)`
1103
+ ///
1104
+ /// # Errors
1105
+ /// `BuiltinType` results in `Err`
1092
1106
fn try_from ( value : ModuleDefId ) -> Result < Self , Self :: Error > {
1093
1107
match value {
1094
1108
ModuleDefId :: ModuleId ( it) => Ok ( it. into ( ) ) ,
@@ -1107,6 +1121,7 @@ impl TryFrom<ModuleDefId> for AttrDefId {
1107
1121
}
1108
1122
1109
1123
impl From < ItemContainerId > for AttrDefId {
1124
+ /// Match `ItemContainerId` to the `AttrDefId` variant of the same name
1110
1125
fn from ( acid : ItemContainerId ) -> Self {
1111
1126
match acid {
1112
1127
ItemContainerId :: ModuleId ( mid) => AttrDefId :: ModuleId ( mid) ,
@@ -1117,6 +1132,7 @@ impl From<ItemContainerId> for AttrDefId {
1117
1132
}
1118
1133
}
1119
1134
impl From < AssocItemId > for AttrDefId {
1135
+ /// Match `AssocItemId` to the `AttrDefId` variant of the same name
1120
1136
fn from ( assoc : AssocItemId ) -> Self {
1121
1137
match assoc {
1122
1138
AssocItemId :: FunctionId ( it) => AttrDefId :: FunctionId ( it) ,
@@ -1126,6 +1142,7 @@ impl From<AssocItemId> for AttrDefId {
1126
1142
}
1127
1143
}
1128
1144
impl From < VariantId > for AttrDefId {
1145
+ /// Convert the inner of `VariantId` into `AttrDefId`
1129
1146
fn from ( vid : VariantId ) -> Self {
1130
1147
match vid {
1131
1148
VariantId :: EnumVariantId ( id) => id. into ( ) ,
0 commit comments