Skip to content
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

Closed
wants to merge 3 commits into from
Closed

handle error and include some traits #4

wants to merge 3 commits into from

Conversation

malik672
Copy link
Contributor

handled error gracefully
included some necessary traits fro end users

@@ -69,7 +69,16 @@ impl Behavior<()> for Deployer {
pool,
);

messager.send(To::All, serde_json::to_string(&deployment_data)?).await;
Copy link
Collaborator

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

Copy link
Contributor Author

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clippy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clippy?

yeah

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a crate?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malik672 malik672 marked this pull request as draft February 19, 2024 16:28
@malik672
Copy link
Contributor Author

@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

@shuhuiluo
Copy link

@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.

@malik672
Copy link
Contributor Author

@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

Copy link
Collaborator

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

Copy link
Contributor Author

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +72 to +74
let _ = messager
.send(To::All, serde_json::to_string(&deployment_data)?)
.await;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let _ = messager
.send(To::All, serde_json::to_string(&deployment_data)?)
.await;
messager
.send(To::All, serde_json::to_string(&deployment_data)?)
.await?;

Copy link
Collaborator

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!

@malik672 malik672 closed this Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants