Skip to content

Commit 9ca7a50

Browse files
committed
Clippy
1 parent 28e8ba5 commit 9ca7a50

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

crackers_python/src/config/constraint.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,15 @@ impl TryFrom<ConstraintConfig> for PythonConstraintConfig {
1818
fn try_from(value: ConstraintConfig) -> Result<Self, Self::Error> {
1919
let precondition: PythonStateEqualityConstraint = value
2020
.precondition
21-
.map(|f| f.try_into().ok())
22-
.flatten()
21+
.and_then(|f| f.try_into().ok())
2322
.unwrap_or_default();
2423
let postcondition: PythonStateEqualityConstraint = value
2524
.postcondition
26-
.map(|f| f.try_into().ok())
27-
.flatten()
25+
.and_then(|f| f.try_into().ok())
2826
.unwrap_or_default();
2927
let pointer: PythonPointerRangeConstraints = value
3028
.pointer
31-
.map(|f| f.try_into().ok())
32-
.flatten()
29+
.and_then(|f| f.try_into().ok())
3330
.unwrap_or_default();
3431
Python::with_gil(|py| {
3532
Ok(Self {
@@ -41,6 +38,7 @@ impl TryFrom<ConstraintConfig> for PythonConstraintConfig {
4138
}
4239
}
4340

41+
#[derive(Default)]
4442
#[pyclass(get_all)]
4543
pub struct PythonStateEqualityConstraint {
4644
pub register: HashMap<String, i64>,
@@ -49,15 +47,7 @@ pub struct PythonStateEqualityConstraint {
4947
pub memory: Option<Py<MemoryEqualityConstraint>>,
5048
}
5149

52-
impl Default for PythonStateEqualityConstraint {
53-
fn default() -> Self {
54-
Self {
55-
register: HashMap::new(),
56-
pointer: HashMap::new(),
57-
memory: None,
58-
}
59-
}
60-
}
50+
6151

6252
impl TryFrom<StateEqualityConstraint> for PythonStateEqualityConstraint {
6353
type Error = PyErr;
@@ -66,8 +56,8 @@ impl TryFrom<StateEqualityConstraint> for PythonStateEqualityConstraint {
6656
Python::with_gil(|py| {
6757
let mem = value.memory.map(|f| Py::new(py, f).unwrap());
6858
Ok(Self {
69-
register: value.register.clone().unwrap_or(HashMap::new()),
70-
pointer: value.pointer.clone().unwrap_or(HashMap::new()),
59+
register: value.register.clone().unwrap_or_default(),
60+
pointer: value.pointer.clone().unwrap_or_default(),
7161
memory: mem,
7262
})
7363
})

0 commit comments

Comments
 (0)