-
Notifications
You must be signed in to change notification settings - Fork 56
Migrate to Rust 2024 Edition #254
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
base: master
Are you sure you want to change the base?
Conversation
fae8f42 to
8450bcd
Compare
micprog
left a comment
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.
Some comments to help my understanding of the changes.
| eprintln!("{}", e); | ||
| std::process::exit(1); |
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 part needed?
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.
You still need to return a a non-zero exit code somehow. You could also return a result instead, which will actually do the same thing:
fn main() -> Result<(), Box<dyn std::error::Error>> {
bender::cli::main()?;
Ok(())
}However, the error will be debug formatted which is a bit uglz
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.
Ok, I see the point! The current setup drops the preceding "error:" in red, if I'm not mistaken, so some adjustment is still needed... Is this where using anyhow or thiserror could be useful?
| } | ||
| }); | ||
| dep_refs_and_revs.and_then(move |(refs, revs)| { | ||
| dep_refs_and_revs.map(move |(refs, revs)| { |
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 not entirely sure this is the correct way to handle this... There may be a simpler way.
| ) | ||
| .await | ||
| .and_then(move |path| { | ||
| .inspect(move |&path| { |
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 not sure this is the correct way to handle this. If I'm not mistaken, this is a remnant from the original futures implementation, that was updated with async/await, but can probably be simplified now.
| } | ||
| }) | ||
| .and_then(move |manifest| { | ||
| .inspect(move |&manifest| { |
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.
See above comments.
3655b98 to
8e4b633
Compare
bin: Rename `main.rs` to `bender.rs` Otherwise, the executable is called `main`
8e4b633 to
6ffb29c
Compare
Bumps the Rust edition from 2018 to 2024, and modernizes the project structure in the following way:
lib.rsfile collects all the modules (previously done inmain.rs), which is the new entry point of bender. This technically means that bender can now also be used as a library crate and not only a binary crate.main.rsis moved tobin/bender.rsand calls the bender library now (with thebender::prefix)extern crateare removed (not required anymore since the 2018 edition).cmd/mod.rsis replaced withcmd.rs, which collects all modules incmdFurthermore, new Rust editions typically change some formatting rules and some new clippy warnings surfaced (e.g. unused functions), which were fixed.