@@ -16,7 +16,7 @@ use pyo3::{
1616} ;
1717use std:: sync:: { Arc , Mutex } ;
1818
19- #[ pyclass( module = "fable" , subclass) ]
19+ #[ pyclass( module = "fable" , subclass, from_py_object ) ]
2020#[ derive( Clone , Debug ) ]
2121
2222pub struct FSharpArray {
@@ -480,7 +480,11 @@ impl FSharpArray {
480480 pub fn __iter__ ( slf : PyRef < ' _ , Self > , py : Python < ' _ > ) -> PyResult < Py < PyAny > > {
481481 let len = slf. storage . len ( ) ;
482482 // SAFETY: slf.as_ptr() is valid and from_borrowed_ptr increments refcount
483- let array: Py < FSharpArray > = unsafe { Py :: from_borrowed_ptr ( py, slf. as_ptr ( ) ) } ;
483+ let array: Py < FSharpArray > = unsafe {
484+ Bound :: from_borrowed_ptr ( py, slf. as_ptr ( ) )
485+ . cast_into_unchecked :: < FSharpArray > ( )
486+ }
487+ . unbind ( ) ;
484488 let iter = FSharpArrayIter {
485489 array,
486490 index : 0 ,
@@ -496,7 +500,11 @@ impl FSharpArray {
496500 pub fn GetEnumerator ( slf : PyRef < ' _ , Self > , py : Python < ' _ > , _unit : Option < & Bound < ' _ , PyAny > > ) -> PyResult < Py < PyAny > > {
497501 let len = slf. storage . len ( ) ;
498502 // SAFETY: slf.as_ptr() is valid and from_borrowed_ptr increments refcount
499- let array: Py < FSharpArray > = unsafe { Py :: from_borrowed_ptr ( py, slf. as_ptr ( ) ) } ;
503+ let array: Py < FSharpArray > = unsafe {
504+ Bound :: from_borrowed_ptr ( py, slf. as_ptr ( ) )
505+ . cast_into_unchecked :: < FSharpArray > ( )
506+ }
507+ . unbind ( ) ;
500508 let enumerator = FSharpArrayEnumerator {
501509 array,
502510 index : -1 , // Before first element
@@ -4377,7 +4385,7 @@ pub fn of_seq(
43774385}
43784386
43794387// Constructor class for array allocation
4380- #[ pyclass( module = "fable" ) ]
4388+ #[ pyclass( module = "fable" , from_py_object ) ]
43814389#[ derive( Clone ) ]
43824390struct FSharpCons {
43834391 #[ pyo3( get, set) ]
0 commit comments