-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clippy #50
Clippy #50
Conversation
This is excellent, thank you! CEL programs actually are multi-threaded (https://github.com/clarkmcc/cel-rust/blob/master/example/src/threads.rs) hence the Arc. They actually used to be Rc back in the day! |
So either these instances would suffice as plain |
Added a few clean ups, also misread the clippy issue with these I'll look in the Feel free to disagree with any of the above changes (kept them isolated in discrete commits)... |
Ah, found it. Index: interpreter/src/objects.rs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/interpreter/src/objects.rs b/interpreter/src/objects.rs
--- a/interpreter/src/objects.rs (revision 45c883d5fc4c8a26f200ce8bbf3d8ae75ab2624a)
+++ b/interpreter/src/objects.rs (date 1718806273985)
@@ -16,7 +16,7 @@
#[derive(Debug, PartialEq, Clone)]
pub struct Map {
- pub map: Rc<HashMap<Key, Value>>,
+ pub map: Arc<HashMap<Key, Value>>,
}
impl PartialOrd for Map {
@@ -126,7 +126,7 @@
new_map.insert(k.into(), v.into());
}
Map {
- map: Rc::new(new_map),
+ map: Arc::new(new_map),
}
}
}
@@ -516,7 +516,10 @@
let value = Value::resolve(v, ctx)?;
map.insert(key, value);
}
- Value::Map(Map { map: Rc::from(map) }).into()
+ Value::Map(Map {
+ map: Arc::from(map),
+ })
+ .into()
}
Expression::Ident(name) => {
if ctx.has_function(&***name) {
@@ -686,7 +689,7 @@
for (k, v) in r.map.iter() {
new.insert(k.clone(), v.clone());
}
- Value::Map(Map { map: Rc::new(new) })
+ Value::Map(Map { map: Arc::new(new) })
}
(Value::Duration(l), Value::Duration(r)) => Value::Duration(l + r),
(Value::Timestamp(l), Value::Duration(r)) => Value::Timestamp(l + r),
@@ -860,6 +863,5 @@
let program = Program::compile("size == 50").unwrap();
let value = program.execute(&context).unwrap();
assert_eq!(value, false.into());
-
}
}
Yes I've seen this one. I'd be open to renaming to |
Probably not Only two hard things in computer science, eh?! 😉 I'd go with |
Correct, yes I'd be good with either suggestion! Take your pick. |
Dunno if having rustfmt check & clippy at the github action level is something you'd want, but I took the freedom to add it... Can easily drop the commit if needed. Finally the Now confused by the test run failures... They reported rustc error don't point to the code as I have it 🤔 |
Passes here... confused |
Rebased 🤦 Sorry for all the noise... hadn't updated my own fork(s)/clone(s) with my own changes... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm interested in any and all improvements that make the project better including the Github actions changes. Thank you very much!
I don't know that you actually want this, but did a run of
cargo clippy --fix
and followed up with a rustfmt...Now, clippy seems to highlight a few warnings still...
The
Arc
one also caught my attention when working on #48 ... Correct me if I'm wrong, but there is no support for multithreading in CEL, is there? So are you planning on making the interpreter mutlithreaded eventually? Or should I take a stab at making all theArc
justRc
?