@@ -299,8 +299,8 @@ impl<S> SchemaType<S> {
299299 }
300300
301301 /// Add a description.
302- pub fn set_description ( & mut self , description : ArcStr ) {
303- self . description = Some ( description) ;
302+ pub fn set_description ( & mut self , description : impl Into < ArcStr > ) {
303+ self . description = Some ( description. into ( ) ) ;
304304 }
305305
306306 /// Add a directive like `skip` or `include`.
@@ -309,16 +309,16 @@ impl<S> SchemaType<S> {
309309 }
310310
311311 /// Get a type by name.
312- pub fn type_by_name ( & self , name : & str ) -> Option < TypeType < S > > {
313- self . types . get ( name) . map ( |t| TypeType :: Concrete ( t) )
312+ pub fn type_by_name ( & self , name : impl AsRef < str > ) -> Option < TypeType < S > > {
313+ self . types . get ( name. as_ref ( ) ) . map ( |t| TypeType :: Concrete ( t) )
314314 }
315315
316316 /// Get a concrete type by name.
317- pub fn concrete_type_by_name ( & self , name : & str ) -> Option < & MetaType < S > > {
318- self . types . get ( name)
317+ pub fn concrete_type_by_name ( & self , name : impl AsRef < str > ) -> Option < & MetaType < S > > {
318+ self . types . get ( name. as_ref ( ) )
319319 }
320320
321- pub ( crate ) fn lookup_type < N : AsRef < str > > ( & self , tpe : & Type < N > ) -> Option < & MetaType < S > > {
321+ pub ( crate ) fn lookup_type ( & self , tpe : & Type < impl AsRef < str > > ) -> Option < & MetaType < S > > {
322322 match tpe {
323323 Type :: Named ( name) | Type :: NonNullNamed ( name) => {
324324 self . concrete_type_by_name ( name. as_ref ( ) )
@@ -745,15 +745,14 @@ mod concrete_type_sort {
745745 }
746746}
747747
748- /// Allows seeing [Type] with different name/string representations
749- /// as the same type without allocating.
750- //
751- // TODO: Ideally this type should not exist, but the reason it currently does
752- // is that [Type] has a recursive design to allow arbitrary number of list wrappings.
753- // The list layout could instead be modelled as a modifier so that type becomes a tuple of (name, modifier).
754- //
755- // If [Type] is modelled like this it becomes easier to project it as a borrowed version of itself,
756- // i.e. [Type<ArcStr>] vs [Type<&str>].
748+ /// Allows seeing [`Type`] with different name/string representations
749+ /// as the same type without allocation.
750+ // TODO: Ideally this type should not exist, but the reason it currently does is that `Type` has a
751+ // recursive design to allow arbitrary number of list wrappings.
752+ // The list layout could instead be modelled as a modifier so that type becomes a tuple of
753+ // (name, modifier).
754+ // If `Type` is modelled like this it becomes easier to project it as a borrowed version of
755+ // itself, i.e. [Type<ArcStr>] vs [Type<&str>].
757756#[ derive( Clone , Copy , Debug ) ]
758757pub enum DynType < ' a > {
759758 Named ( & ' a str ) ,
@@ -765,12 +764,12 @@ pub enum DynType<'a> {
765764impl < ' a > DynType < ' a > {
766765 pub fn equals ( & self , other : & DynType ) -> bool {
767766 match ( self , other) {
768- ( DynType :: Named ( n0) , DynType :: Named ( n1) ) => n0 == n1,
769- ( DynType :: List ( t0, s0) , DynType :: List ( t1, s1) ) => {
767+ ( Self :: Named ( n0) , DynType :: Named ( n1) ) => n0 == n1,
768+ ( Self :: List ( t0, s0) , DynType :: List ( t1, s1) ) => {
770769 t0. as_dyn_type ( ) . equals ( & t1. as_dyn_type ( ) ) && s0 == s1
771770 }
772- ( DynType :: NonNullNamed ( n0) , DynType :: NonNullNamed ( n1) ) => n0 == n1,
773- ( DynType :: NonNullList ( t0, s0) , DynType :: NonNullList ( t1, s1) ) => {
771+ ( Self :: NonNullNamed ( n0) , DynType :: NonNullNamed ( n1) ) => n0 == n1,
772+ ( Self :: NonNullList ( t0, s0) , DynType :: NonNullList ( t1, s1) ) => {
774773 t0. as_dyn_type ( ) . equals ( & t1. as_dyn_type ( ) ) && s0 == s1
775774 }
776775 _ => false ,
@@ -796,11 +795,11 @@ impl fmt::Display for DynType<'_> {
796795 }
797796}
798797
799- /// Trait for converting a [Type] into [ DynType]
798+ /// Conversion of a [` Type` ] into a [` DynType`].
800799pub trait AsDynType : fmt:: Debug {
801- /// Project [self] as a [DynType].
800+ /// Project this value as a [` DynType` ].
802801 ///
803- /// this function should not allocate memory.
802+ /// Should not allocate memory.
804803 fn as_dyn_type ( & self ) -> DynType < ' _ > ;
805804}
806805
0 commit comments