Skip to content

Commit 4365f3d

Browse files
Minimize size
1 parent 2e645e7 commit 4365f3d

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

src/conversions.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ fn repr(py: Python, obj: PyObject) -> PyResult<String> {
2323
obj.call_method(py, "__repr__", (), None)?.extract(py)
2424
}
2525

26-
trait SizedIntoPy: IntoPy<PyObject> + Sized {}
27-
2826
// Create a dataclass-like repr, of the name of the class of the object
2927
// called with the repr of the fields
3028
fn data_repr(py: Python, obj: PyObject, field_names: Vec<&str>) -> PyResult<String> {
@@ -39,12 +37,12 @@ fn data_repr(py: Python, obj: PyObject, field_names: Vec<&str>) -> PyResult<Stri
3937
Ok(format!("{}({})", class_name, field_strings?.join(", ")))
4038
}
4139

42-
#[pyclass(name = "Variant")]
40+
#[pyclass]
4341
#[derive(Clone)]
44-
pub(crate) struct WrappedVariant(egg_smol::ast::Variant);
42+
pub struct Variant(pub egg_smol::ast::Variant);
4543

4644
#[pymethods]
47-
impl WrappedVariant {
45+
impl Variant {
4846
#[new]
4947
fn new(name: String, types: Vec<String>, cost: Option<usize>) -> Self {
5048
Self(egg_smol::ast::Variant {
@@ -75,18 +73,6 @@ impl WrappedVariant {
7573
}
7674
}
7775

78-
impl From<WrappedVariant> for egg_smol::ast::Variant {
79-
fn from(other: WrappedVariant) -> Self {
80-
other.0
81-
}
82-
}
83-
84-
impl From<egg_smol::ast::Variant> for WrappedVariant {
85-
fn from(other: egg_smol::ast::Variant) -> Self {
86-
WrappedVariant(other)
87-
}
88-
}
89-
9076
// Wrapped version of FunctionDecl
9177
pub struct WrappedFunctionDecl(egg_smol::ast::FunctionDecl);
9278
impl FromPyObject<'_> for WrappedFunctionDecl {

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ impl EGraph {
9494

9595
/// Declare a new datatype constructor.
9696
#[pyo3(text_signature = "($self, variant, sort)")]
97-
fn declare_constructor(&mut self, variant: WrappedVariant, sort: &str) -> EggResult<()> {
98-
self.egraph.declare_constructor(variant.into(), sort)?;
97+
fn declare_constructor(&mut self, variant: Variant, sort: &str) -> EggResult<()> {
98+
self.egraph.declare_constructor(variant.0, sort)?;
9999
Ok({})
100100
}
101101

@@ -114,6 +114,6 @@ impl EGraph {
114114
fn bindings(_py: Python, m: &PyModule) -> PyResult<()> {
115115
m.add_class::<EGraph>()?;
116116
m.add_class::<EggSmolError>()?;
117-
m.add_class::<WrappedVariant>()?;
117+
m.add_class::<Variant>()?;
118118
Ok(())
119119
}

0 commit comments

Comments
 (0)