Skip to content

Commit 7a615e9

Browse files
Rust fix comment
1 parent 6a9bb82 commit 7a615e9

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/extract.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
1-
use std::{cmp::Ordering, sync::Arc};
1+
use std::cmp::Ordering;
22

33
use pyo3::{exceptions::PyValueError, prelude::*};
44

55
use crate::{conversions::Term, egraph::EGraph, egraph::Value, termdag::TermDag};
66

77
#[derive(Debug)]
8-
// Wrap in Arc so we can clone efficiently
9-
// https://pyo3.rs/main/migration.html#pyclone-is-now-gated-behind-the-py-clone-feature
10-
// We also have to store the result, since the cost model does not return errors
8+
// We have to store the result, since the cost model does not return errors
119
struct Cost(PyResult<Py<PyAny>>);
1210

13-
impl Clone for Cost {
14-
fn clone(&self) -> Self {
15-
Python::attach(|py| {
16-
Cost(match &self.0 {
17-
Ok(v) => Ok(v.clone_ref(py)),
18-
Err(e) => Err(e.clone_ref(py)),
19-
})
20-
})
21-
}
22-
}
23-
2411
impl Ord for Cost {
2512
fn cmp(&self, other: &Self) -> Ordering {
2613
// Always order errors as smallest cost so they are prefered
@@ -53,6 +40,17 @@ impl PartialEq for Cost {
5340

5441
impl Eq for Cost {}
5542

43+
impl Clone for Cost {
44+
fn clone(&self) -> Self {
45+
Python::attach(|py| {
46+
Cost(match &self.0 {
47+
Ok(v) => Ok(v.clone_ref(py)),
48+
Err(e) => Err(e.clone_ref(py)),
49+
})
50+
})
51+
}
52+
}
53+
5654
impl egglog::extract::Cost for Cost {
5755
fn identity() -> Self {
5856
panic!("Should never be called from Rust directly");
@@ -175,6 +173,7 @@ impl egglog::extract::CostModel<Cost> for CostModel {
175173
}
176174
}
177175

176+
// TODO: Don't progress just return an error if there was an exception?
178177

179178
#[pyclass(unsendable)]
180179
pub struct Extractor(egglog::extract::Extractor<Cost>);

0 commit comments

Comments
 (0)