-
Notifications
You must be signed in to change notification settings - Fork 11
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
handle error and include some traits #4
Conversation
@@ -69,7 +69,16 @@ impl Behavior<()> for Deployer { | |||
pool, | |||
); | |||
|
|||
messager.send(To::All, serde_json::to_string(&deployment_data)?).await; |
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.
Could just ?
here to save LOC as it is effectively the same thing
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.
yeah, prefer using this ? tbh, mistake on my path
@@ -12,5 +12,5 @@ async fn main() { | |||
let deployer = Agent::builder("deployer").with_behavior(Deployer); | |||
|
|||
world.add_agent(deployer); | |||
world.run().await; | |||
let _ = world.run().await; |
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.
For clippy?
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.
For clippy?
yeah
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.
is this a crate?
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.
A very good linter: https://doc.rust-lang.org/stable/clippy/usage.html
@Autoparallel i don't understand some part, why do we have to manually implement debug and clone when we can just use derive in bitmath.rs |
The bindings are codegen-ed by ethers-rs. |
probably why it's getting depreceated |
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.
Let's not change any bindings files as they are quite finnicky and autogenned
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.
@Autoparallel yep, will close this
@@ -12,5 +12,5 @@ async fn main() { | |||
let deployer = Agent::builder("deployer").with_behavior(Deployer); | |||
|
|||
world.add_agent(deployer); | |||
world.run().await; | |||
let _ = world.run().await; |
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.
A very good linter: https://doc.rust-lang.org/stable/clippy/usage.html
let _ = messager | ||
.send(To::All, serde_json::to_string(&deployment_data)?) | ||
.await; |
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.
let _ = messager | |
.send(To::All, serde_json::to_string(&deployment_data)?) | |
.await; | |
messager | |
.send(To::All, serde_json::to_string(&deployment_data)?) | |
.await?; |
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.
Usually prefer to use the ?
and not even catch the errors manually unless I need to do something with them. https://doc.rust-lang.org/rust-by-example/std/result/question_mark.html
The linter gets mad when you do messager.send(_).await
as the Result<_,_>
type is tagged by clippy as must_use
. By doing let _ = messager.send(_).await
what happens is that the Result
is actually immediately dropped and we won't know if it is Ok
or Err
!
handled error gracefully
included some necessary traits fro end users