@@ -16,7 +16,7 @@ pub(crate) mod _struct {
16
16
function:: { ArgBytesLike , ArgMemoryBuffer , PosArgs } ,
17
17
match_class,
18
18
protocol:: PyIterReturn ,
19
- types:: { Constructor , IterNext , Iterable , Representable , SelfIter } ,
19
+ types:: { Constructor , IterNext , Iterable , Representable , SelfIter , Unconstructible } ,
20
20
} ;
21
21
use crossbeam_utils:: atomic:: AtomicCell ;
22
22
@@ -163,7 +163,7 @@ pub(crate) mod _struct {
163
163
}
164
164
165
165
impl UnpackIterator {
166
- fn new (
166
+ fn with_buffer (
167
167
vm : & VirtualMachine ,
168
168
format_spec : FormatSpec ,
169
169
buffer : ArgBytesLike ,
@@ -191,14 +191,15 @@ pub(crate) mod _struct {
191
191
}
192
192
}
193
193
194
- #[ pyclass( with( IterNext , Iterable ) ) ]
194
+ #[ pyclass( with( Unconstructible , IterNext , Iterable ) ) ]
195
195
impl UnpackIterator {
196
196
#[ pymethod( magic) ]
197
197
fn length_hint ( & self ) -> usize {
198
198
self . buffer . len ( ) . saturating_sub ( self . offset . load ( ) ) / self . format_spec . size
199
199
}
200
200
}
201
201
impl SelfIter for UnpackIterator { }
202
+ impl Unconstructible for UnpackIterator { }
202
203
impl IterNext for UnpackIterator {
203
204
fn next ( zelf : & Py < Self > , vm : & VirtualMachine ) -> PyResult < PyIterReturn > {
204
205
let size = zelf. format_spec . size ;
@@ -222,7 +223,7 @@ pub(crate) mod _struct {
222
223
vm : & VirtualMachine ,
223
224
) -> PyResult < UnpackIterator > {
224
225
let format_spec = fmt. format_spec ( vm) ?;
225
- UnpackIterator :: new ( vm, format_spec, buffer)
226
+ UnpackIterator :: with_buffer ( vm, format_spec, buffer)
226
227
}
227
228
228
229
#[ pyfunction]
@@ -302,7 +303,7 @@ pub(crate) mod _struct {
302
303
buffer : ArgBytesLike ,
303
304
vm : & VirtualMachine ,
304
305
) -> PyResult < UnpackIterator > {
305
- UnpackIterator :: new ( vm, self . spec . clone ( ) , buffer)
306
+ UnpackIterator :: with_buffer ( vm, self . spec . clone ( ) , buffer)
306
307
}
307
308
}
308
309
0 commit comments