@@ -92,12 +92,19 @@ impl<'py> PythonizeMappingType<'py> for PyDict {
9292 }
9393}
9494
95- pub struct PythonizeUnnamedMappingWrapper < ' py , T : PythonizeMappingType < ' py > > {
95+ /// Adapter type to use an unnamed mapping type, i.e. one that implements
96+ /// [`PythonizeMappingType`], as a named mapping type, i.e. one that implements
97+ /// [`PythonizeNamedMappingType`]. The adapter simply drops the provided name.
98+ ///
99+ /// This adapter is commonly applied to use the same unnamed mapping type for
100+ /// both [`PythonizeTypes::Map`] and [`PythonizeTypes::NamedMap`] while only
101+ /// implementing [`PythonizeMappingType`].
102+ pub struct PythonizeUnnamedMappingAdapter < ' py , T : PythonizeMappingType < ' py > > {
96103 unnamed : T ,
97104 _marker : PhantomData < & ' py ( ) > ,
98105}
99106
100- impl < ' py , T : PythonizeMappingType < ' py > > PythonizeUnnamedMappingWrapper < ' py , T > {
107+ impl < ' py , T : PythonizeMappingType < ' py > > PythonizeUnnamedMappingAdapter < ' py , T > {
101108 #[ must_use]
102109 pub fn new ( unnamed : T ) -> Self {
103110 Self {
@@ -112,14 +119,14 @@ impl<'py, T: PythonizeMappingType<'py>> PythonizeUnnamedMappingWrapper<'py, T> {
112119 }
113120}
114121
115- impl < ' py , T : PythonizeMappingType < ' py > > From < T > for PythonizeUnnamedMappingWrapper < ' py , T > {
122+ impl < ' py , T : PythonizeMappingType < ' py > > From < T > for PythonizeUnnamedMappingAdapter < ' py , T > {
116123 fn from ( value : T ) -> Self {
117124 Self :: new ( value)
118125 }
119126}
120127
121128impl < ' py , T : PythonizeMappingType < ' py > > PythonizeNamedMappingType < ' py >
122- for PythonizeUnnamedMappingWrapper < ' py , T >
129+ for PythonizeUnnamedMappingAdapter < ' py , T >
123130{
124131 type Builder = <T as PythonizeMappingType < ' py > >:: Builder ;
125132
@@ -173,7 +180,7 @@ pub struct PythonizeDefault;
173180
174181impl < ' py > PythonizeTypes < ' py > for PythonizeDefault {
175182 type Map = PyDict ;
176- type NamedMap = PythonizeUnnamedMappingWrapper < ' py , PyDict > ;
183+ type NamedMap = PythonizeUnnamedMappingAdapter < ' py , PyDict > ;
177184 type List = PyList ;
178185}
179186
0 commit comments