@@ -327,6 +327,8 @@ impl StructBindGenerator {
327327 String :: from ( "Option<crate::Floats>" )
328328 } else if inner_type == "Bool" {
329329 String :: from ( "Option<crate::Bools>" )
330+ } else if self . is_frozen {
331+ format ! ( "Option<super::{inner_type}>" )
330332 } else {
331333 format ! ( "Option<Py<super::{inner_type}>>" )
332334 } ) ,
@@ -690,7 +692,13 @@ impl Generator for StructBindGenerator {
690692 }
691693 RustType :: Option ( InnerOptionType :: BaseType , inner_type)
692694 | RustType :: Option ( InnerOptionType :: String , inner_type) => format ! ( "Option<{inner_type}>" ) ,
693- RustType :: Option ( _, inner_type) => format ! ( "Option<Py<super::{inner_type}>>" ) ,
695+ RustType :: Option ( _, inner_type) => {
696+ if self . is_frozen {
697+ format ! ( "Option<super::{inner_type}>" )
698+ } else {
699+ format ! ( "Option<Py<super::{inner_type}>>" )
700+ }
701+ }
694702 RustType :: Base ( inner_type) => inner_type. clone ( ) ,
695703 RustType :: String => String :: from ( "String" ) ,
696704 RustType :: Union ( inner_type) | RustType :: Custom ( inner_type) => {
@@ -810,9 +818,15 @@ impl Generator for StructBindGenerator {
810818 }
811819 }
812820 RustType :: Option ( InnerOptionType :: Box , _) => {
821+ let inner = if self . is_frozen {
822+ "(*x).into()"
823+ } else {
824+ "crate::into_py_from(py, *x)"
825+ } ;
826+
813827 write_fmt ! (
814828 self ,
815- " {variable_name}: flat_t.{variable_name}.map(|x| crate::into_py_from(py, *x) ),"
829+ " {variable_name}: flat_t.{variable_name}.map(|x| {inner} ),"
816830 ) ;
817831 }
818832 RustType :: Option ( InnerOptionType :: String , _) => {
@@ -930,7 +944,13 @@ impl Generator for StructBindGenerator {
930944 }
931945 }
932946 RustType :: Option ( InnerOptionType :: Box , _) => {
933- write_fmt ! ( self , " {variable_name}: py_type.{variable_name}.as_ref().map(|x| Box::new(crate::from_py_into(py, x)))," ) ;
947+ let inner = if self . is_frozen {
948+ "x.into()"
949+ } else {
950+ "crate::from_py_into(py, x)"
951+ } ;
952+
953+ write_fmt ! ( self , " {variable_name}: py_type.{variable_name}.as_ref().map(|x| Box::new({inner}))," ) ;
934954 }
935955 RustType :: Option ( InnerOptionType :: String , _) => {
936956 write_fmt ! ( self , " {variable_name}: py_type.{variable_name}.clone()," ) ;
0 commit comments