lifetime insanity

This commit is contained in:
Jack O'Connor 2025-07-31 11:04:59 -07:00
parent 6453a0ba48
commit 36a8edaf4b
2 changed files with 17 additions and 9 deletions

View File

@ -490,13 +490,16 @@ impl<'db> PyIndex<'db> for &FixedLengthTuple<Type<'db>> {
impl<'db> PySlice<'db> for FixedLengthTuple<Type<'db>> { impl<'db> PySlice<'db> for FixedLengthTuple<Type<'db>> {
type Item = Type<'db>; type Item = Type<'db>;
fn py_slice( fn py_slice<'self_>(
&'db self, &'self_ self,
db: &'db dyn Db, db: &'db dyn Db,
start: Option<i32>, start: Option<i32>,
stop: Option<i32>, stop: Option<i32>,
step: Option<i32>, step: Option<i32>,
) -> Result<impl Iterator<Item = &'db Self::Item>, StepSizeZeroError> { ) -> Result<impl Iterator<Item = &'self_ Self::Item>, StepSizeZeroError>
where
'db: 'self_,
{
self.0.py_slice(db, start, stop, step) self.0.py_slice(db, start, stop, step)
} }
} }

View File

@ -110,25 +110,30 @@ pub(crate) struct StepSizeZeroError;
pub(crate) trait PySlice<'db> { pub(crate) trait PySlice<'db> {
type Item: 'db; type Item: 'db;
fn py_slice( fn py_slice<'self_>(
&'db self, &'self_ self,
db: &'db dyn Db, db: &'db dyn Db,
start: Option<i32>, start: Option<i32>,
stop: Option<i32>, stop: Option<i32>,
step: Option<i32>, step: Option<i32>,
) -> Result<impl Iterator<Item = &'db Self::Item>, StepSizeZeroError>; ) -> Result<impl Iterator<Item = &'self_ Self::Item>, StepSizeZeroError>
where
'db: 'self_;
} }
impl<'db, T: 'db> PySlice<'db> for [T] { impl<'db, T: 'db> PySlice<'db> for [T] {
type Item = T; type Item = T;
fn py_slice( fn py_slice<'self_>(
&'db self, &'self_ self,
_db: &'db dyn Db, _db: &'db dyn Db,
start: Option<i32>, start: Option<i32>,
stop: Option<i32>, stop: Option<i32>,
step_int: Option<i32>, step_int: Option<i32>,
) -> Result<impl Iterator<Item = &'db Self::Item>, StepSizeZeroError> { ) -> Result<impl Iterator<Item = &'self_ Self::Item>, StepSizeZeroError>
where
'db: 'self_,
{
let step_int = step_int.unwrap_or(1); let step_int = step_int.unwrap_or(1);
if step_int == 0 { if step_int == 0 {
return Err(StepSizeZeroError); return Err(StepSizeZeroError);