Skip to content

Commit 5a8ef29

Browse files
committed
Remove nightly feature
1 parent 5a92708 commit 5a8ef29

File tree

5 files changed

+0
-104
lines changed

5 files changed

+0
-104
lines changed

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ rustversion = "1.0"
3636
default = ["macros"]
3737
macros = ["ctor", "indoc", "inventory", "paste", "pyo3cls", "unindent"]
3838

39-
# Supports arrays of arbitrary size
40-
const-generics = []
41-
4239
# Optimizes PyObject to Vec conversion and so on.
4340
nightly = []
4441

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg_attr(feature = "const-generics", feature(min_const_generics))]
2-
#![cfg_attr(feature = "nightly", allow(incomplete_features))]
31
#![cfg_attr(feature = "nightly", feature(specialization))]
42
#![allow(clippy::missing_safety_doc)] // FIXME (#698)
53

src/types/list.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ where
178178
}
179179
}
180180

181-
#[cfg(feature = "const-generics")]
182181
impl<T, const N: usize> IntoPy<PyObject> for [T; N]
183182
where
184183
T: ToPyObject,
@@ -188,28 +187,6 @@ where
188187
}
189188
}
190189

191-
#[cfg(not(feature = "const-generics"))]
192-
macro_rules! array_impls {
193-
($($N:expr),+) => {
194-
$(
195-
impl<T> IntoPy<PyObject> for [T; $N]
196-
where
197-
T: ToPyObject
198-
{
199-
fn into_py(self, py: Python) -> PyObject {
200-
self.as_ref().to_object(py)
201-
}
202-
}
203-
)+
204-
}
205-
}
206-
207-
#[cfg(not(feature = "const-generics"))]
208-
array_impls!(
209-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
210-
26, 27, 28, 29, 30, 31, 32
211-
);
212-
213190
impl<T> ToPyObject for Vec<T>
214191
where
215192
T: ToPyObject,

src/types/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,11 @@ mod string;
236236
mod tuple;
237237
mod typeobject;
238238

239-
#[cfg(feature = "const-generics")]
240239
struct ArrayGuard<T, const N: usize> {
241240
dst: *mut T,
242241
initialized: usize,
243242
}
244243

245-
#[cfg(feature = "const-generics")]
246244
impl<T, const N: usize> Drop for ArrayGuard<T, N> {
247245
fn drop(&mut self) {
248246
debug_assert!(self.initialized <= N);
@@ -253,7 +251,6 @@ impl<T, const N: usize> Drop for ArrayGuard<T, N> {
253251
}
254252
}
255253

256-
#[cfg(feature = "const-generics")]
257254
fn try_create_array<E, F, T, const N: usize>(mut cb: F) -> Result<[T; N], E>
258255
where
259256
F: FnMut(usize) -> Result<T, E>,

src/types/sequence.rs

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ impl PySequence {
257257
}
258258
}
259259

260-
#[cfg(feature = "const-generics")]
261260
impl<'a, T, const N: usize> FromPyObject<'a> for [T; N]
262261
where
263262
T: FromPyObject<'a>,
@@ -273,7 +272,6 @@ where
273272
}
274273
}
275274

276-
#[cfg(all(feature = "const-generics", feature = "nightly"))]
277275
impl<'source, T, const N: usize> FromPyObject<'source> for [T; N]
278276
where
279277
for<'a> T: FromPyObject<'a> + crate::buffer::Element,
@@ -291,59 +289,6 @@ where
291289
}
292290
}
293291

294-
#[cfg(not(feature = "const-generics"))]
295-
macro_rules! array_impls {
296-
($($N:expr),+) => {
297-
$(
298-
impl<'a, T> FromPyObject<'a> for [T; $N]
299-
where
300-
T: Copy + Default + FromPyObject<'a>,
301-
{
302-
#[cfg(not(feature = "nightly"))]
303-
fn extract(obj: &'a PyAny) -> PyResult<Self> {
304-
let mut array = [T::default(); $N];
305-
extract_sequence_into_slice(obj, &mut array)?;
306-
Ok(array)
307-
}
308-
309-
#[cfg(feature = "nightly")]
310-
default fn extract(obj: &'a PyAny) -> PyResult<Self> {
311-
let mut array = [T::default(); $N];
312-
extract_sequence_into_slice(obj, &mut array)?;
313-
Ok(array)
314-
}
315-
}
316-
317-
#[cfg(feature = "nightly")]
318-
impl<'source, T> FromPyObject<'source> for [T; $N]
319-
where
320-
for<'a> T: Default + FromPyObject<'a> + crate::buffer::Element,
321-
{
322-
fn extract(obj: &'source PyAny) -> PyResult<Self> {
323-
let mut array = [T::default(); $N];
324-
// first try buffer protocol
325-
if let Ok(buf) = crate::buffer::PyBuffer::get(obj) {
326-
if buf.dimensions() == 1 && buf.copy_to_slice(obj.py(), &mut array).is_ok() {
327-
buf.release(obj.py());
328-
return Ok(array);
329-
}
330-
buf.release(obj.py());
331-
}
332-
// fall back to sequence protocol
333-
extract_sequence_into_slice(obj, &mut array)?;
334-
Ok(array)
335-
}
336-
}
337-
)+
338-
}
339-
}
340-
341-
#[cfg(not(feature = "const-generics"))]
342-
array_impls!(
343-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
344-
26, 27, 28, 29, 30, 31, 32
345-
);
346-
347292
impl<'a, T> FromPyObject<'a> for Vec<T>
348293
where
349294
T: FromPyObject<'a>,
@@ -379,7 +324,6 @@ where
379324
}
380325
}
381326

382-
#[cfg(feature = "const-generics")]
383327
fn create_array_from_obj<'s, T, const N: usize>(obj: &'s PyAny) -> PyResult<[T; N]>
384328
where
385329
T: FromPyObject<'s>,
@@ -406,23 +350,6 @@ where
406350
Ok(v)
407351
}
408352

409-
#[cfg(not(feature = "const-generics"))]
410-
fn extract_sequence_into_slice<'s, T>(obj: &'s PyAny, slice: &mut [T]) -> PyResult<()>
411-
where
412-
T: FromPyObject<'s>,
413-
{
414-
let seq = <PySequence as PyTryFrom>::try_from(obj)?;
415-
if seq.len()? as usize != slice.len() {
416-
return Err(exceptions::PyBufferError::py_err(
417-
"Slice length does not match buffer length.",
418-
));
419-
}
420-
for (value, item) in slice.iter_mut().zip(seq.iter()?) {
421-
*value = item?.extract::<T>()?;
422-
}
423-
Ok(())
424-
}
425-
426353
impl<'v> PyTryFrom<'v> for PySequence {
427354
fn try_from<V: Into<&'v PyAny>>(value: V) -> Result<&'v PySequence, PyDowncastError<'v>> {
428355
let value = value.into();

0 commit comments

Comments
 (0)