@@ -7,7 +7,7 @@ use crate::pyinterface::text::PyTextContent;
77use pyo3:: exceptions:: PyValueError ;
88use pyo3:: prelude:: PyAnyMethods ;
99use pyo3:: types:: PyList ;
10- use pyo3:: { intern , Bound , FromPyObject , PyAny , PyResult } ;
10+ use pyo3:: { Borrowed , Bound , FromPyObject , PyAny , PyErr , PyResult , intern } ;
1111use renderer:: taffy:: style_helpers:: {
1212 FromFlex , FromLength , FromPercent , TaffyGridLine , TaffyGridSpan ,
1313} ;
@@ -29,8 +29,9 @@ struct PyPage<'py> {
2929
3030struct PyLengthOrExpr ( LengthOrExpr ) ;
3131
32- impl < ' py > FromPyObject < ' py > for PyLengthOrExpr {
33- fn extract_bound ( obj : & Bound < ' py , PyAny > ) -> PyResult < Self > {
32+ impl < ' py > FromPyObject < ' _ , ' py > for PyLengthOrExpr {
33+ type Error = PyErr ;
34+ fn extract ( obj : Borrowed < ' _ , ' py , PyAny > ) -> PyResult < Self > {
3435 Ok ( PyLengthOrExpr ( if let Ok ( value) = obj. extract :: < f32 > ( ) {
3536 LengthOrExpr :: points ( value)
3637 } else if let Ok ( value) = obj. extract :: < & str > ( ) {
@@ -43,8 +44,9 @@ impl<'py> FromPyObject<'py> for PyLengthOrExpr {
4344
4445struct PyLength ( Length ) ;
4546
46- impl < ' py > FromPyObject < ' py > for PyLength {
47- fn extract_bound ( obj : & Bound < ' py , PyAny > ) -> PyResult < Self > {
47+ impl < ' py > FromPyObject < ' _ , ' py > for PyLength {
48+ type Error = PyErr ;
49+ fn extract ( obj : Borrowed < ' _ , ' py , PyAny > ) -> PyResult < Self > {
4850 Ok ( PyLength ( if let Ok ( value) = obj. extract :: < f32 > ( ) {
4951 Length :: Points { value }
5052 } else if let Ok ( value) = obj. extract :: < & str > ( ) {
@@ -57,8 +59,9 @@ impl<'py> FromPyObject<'py> for PyLength {
5759
5860struct PyLengthOrAuto ( LengthOrAuto ) ;
5961
60- impl < ' py > FromPyObject < ' py > for PyLengthOrAuto {
61- fn extract_bound ( obj : & Bound < ' py , PyAny > ) -> PyResult < Self > {
62+ impl < ' py > FromPyObject < ' _ , ' py > for PyLengthOrAuto {
63+ type Error = PyErr ;
64+ fn extract ( obj : Borrowed < ' _ , ' py , PyAny > ) -> PyResult < Self > {
6265 Ok ( PyLengthOrAuto ( if let Ok ( value) = obj. extract :: < f32 > ( ) {
6366 LengthOrAuto :: Length ( Length :: Points { value } )
6467 } else if let Ok ( value) = obj. extract :: < & str > ( ) {
@@ -71,8 +74,9 @@ impl<'py> FromPyObject<'py> for PyLengthOrAuto {
7174
7275struct PyAlignItems ( AlignItems ) ;
7376
74- impl < ' py > FromPyObject < ' py > for PyAlignItems {
75- fn extract_bound ( obj : & Bound < ' py , PyAny > ) -> PyResult < Self > {
77+ impl < ' py > FromPyObject < ' _ , ' py > for PyAlignItems {
78+ type Error = PyErr ;
79+ fn extract ( obj : Borrowed < ' _ , ' py , PyAny > ) -> PyResult < Self > {
7680 let s = obj. extract :: < & str > ( ) ?;
7781 Ok ( PyAlignItems ( match s {
7882 "start" => AlignItems :: Start ,
@@ -95,8 +99,9 @@ impl From<PyAlignItems> for AlignItems {
9599
96100struct PyAlignContent ( AlignContent ) ;
97101
98- impl < ' py > FromPyObject < ' py > for PyAlignContent {
99- fn extract_bound ( obj : & Bound < ' py , PyAny > ) -> PyResult < Self > {
102+ impl < ' py > FromPyObject < ' _ , ' py > for PyAlignContent {
103+ type Error = PyErr ;
104+ fn extract ( obj : Borrowed < ' _ , ' py , PyAny > ) -> PyResult < Self > {
100105 let s = obj. extract :: < & str > ( ) ?;
101106 Ok ( PyAlignContent ( match s {
102107 "start" => AlignContent :: Start ,
@@ -121,8 +126,9 @@ impl From<PyAlignContent> for AlignContent {
121126
122127struct PyGridTemplateItem ( NonRepeatedTrackSizingFunction ) ;
123128
124- impl < ' py > FromPyObject < ' py > for PyGridTemplateItem {
125- fn extract_bound ( obj : & Bound < ' py , PyAny > ) -> PyResult < Self > {
129+ impl < ' py > FromPyObject < ' _ , ' py > for PyGridTemplateItem {
130+ type Error = PyErr ;
131+ fn extract ( obj : Borrowed < ' _ , ' py , PyAny > ) -> PyResult < Self > {
126132 Ok ( PyGridTemplateItem (
127133 if let Ok ( value) = obj. extract :: < f32 > ( ) {
128134 NonRepeatedTrackSizingFunction :: from_length ( value)
@@ -156,7 +162,7 @@ impl From<PyGridTemplateItem> for NonRepeatedTrackSizingFunction {
156162
157163struct PyGridLinePlacement ( Line < GridPlacement > ) ;
158164
159- fn parse_grid_placement_item ( obj : & Bound < PyAny > ) -> PyResult < GridPlacement > {
165+ fn parse_grid_placement_item ( obj : Borrowed < ' _ , ' _ , PyAny > ) -> PyResult < GridPlacement > {
160166 if obj. is_none ( ) {
161167 return Ok ( GridPlacement :: Auto ) ;
162168 }
@@ -180,20 +186,19 @@ fn parse_grid_placement_item(obj: &Bound<PyAny>) -> PyResult<GridPlacement> {
180186 }
181187}
182188
183- impl < ' py > FromPyObject < ' py > for PyGridLinePlacement {
184- fn extract_bound ( obj : & Bound < ' py , PyAny > ) -> PyResult < Self > {
189+ impl < ' py > FromPyObject < ' _ , ' py > for PyGridLinePlacement {
190+ type Error = PyErr ;
191+ fn extract ( obj : Borrowed < ' _ , ' py , PyAny > ) -> PyResult < Self > {
185192 if let Ok ( value) = parse_grid_placement_item ( obj) {
186193 return Ok ( PyGridLinePlacement ( Line {
187194 start : value,
188195 end : GridPlacement :: Auto ,
189196 } ) ) ;
190197 } else if let Ok ( ( value1, value2) ) = obj. extract :: < ( Bound < ' py , PyAny > , Bound < ' py , PyAny > ) > ( )
198+ && let Ok ( start) = parse_grid_placement_item ( value1. as_borrowed ( ) )
199+ && let Ok ( end) = parse_grid_placement_item ( value2. as_borrowed ( ) )
191200 {
192- if let Ok ( start) = parse_grid_placement_item ( & value1) {
193- if let Ok ( end) = parse_grid_placement_item ( & value2) {
194- return Ok ( PyGridLinePlacement ( Line { start, end } ) ) ;
195- }
196- }
201+ return Ok ( PyGridLinePlacement ( Line { start, end } ) ) ;
197202 }
198203 Err ( PyValueError :: new_err ( "Invalid grid placement" ) )
199204 }
0 commit comments