Skip to content

Commit

Permalink
Remove IntoPyObject<'py> for Span
Browse files Browse the repository at this point in the history
  • Loading branch information
bschoenmaeckers committed Jan 19, 2025
1 parent 2a3d91b commit 773885b
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/conversions/jiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,21 +619,6 @@ impl<'py> FromPyObject<'py> for SignedDuration {
}
}

impl<'py> IntoPyObject<'py> for Span {
#[cfg(not(Py_LIMITED_API))]
type Target = PyDelta;
#[cfg(Py_LIMITED_API)]
type Target = PyAny;
type Output = Bound<'py, Self::Target>;
type Error = PyErr;

fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
// This can fail if this Span contains units greater than days.
let duration: SignedDuration = self.try_into()?;
duration.into_pyobject(py)
}
}

impl<'py> FromPyObject<'py> for Span {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
let duration = ob.extract::<SignedDuration>()?;
Expand Down Expand Up @@ -1206,7 +1191,8 @@ mod tests {
// python values of durations (from -999999999 to 999999999 days),
Python::with_gil(|py| {
if let Ok(span) = Span::new().try_days(days) {
let py_delta = span.into_pyobject(py).unwrap();
let date = Date::new(2025, 1, 1).unwrap();
let py_delta = span.to_jiff_duration(date).unwrap().into_pyobject(py).unwrap();
let roundtripped: Span = py_delta.extract().expect("Round trip");
assert_eq!(span.compare(roundtripped).unwrap(), Ordering::Equal);
}
Expand Down

0 comments on commit 773885b

Please sign in to comment.