Rust, Software Development

Rust Stable And Rocket 0.5 Latest Development Codes

As posted in Rust Framework Rocket Goes Stable, Rocket will be compatible with Rust Stable, starting with version 0.5. It is almost September, and we will have the new release any time soon. We can already use the latest Rocket codes from the master branch for non-production codes for those who cannot contain their excitement. This post shows how to use the newest Rocket web framework development codes from GitHub using Rust stable.

Ensure We Are Using Atleast Rust Stable 1.45.0

Please run the following command on the command line to check the version of our Rust stable.

For this post, we are using Rust 1.46.0.

Create A Rust Project

This post uses IntelliJ IDEA and an IntelliJ Rust plugin to hasten the creation of a Rust project. Alternatively, we can use the Cargo CLI tools.

Modify Cargo.toml To Use Rocket 0.5 (Latest Development Codes)

Then, modify the Cargo.toml file, as shown below.

In the file, we indicated a dependency on the Rocket framework codes (not a crate) in GitHub. The git property refers to the Git repository URL, while the branch property refers to the branch we will use.

Rust Rocket GitHub Repository

As we can see, the latest release is still Rocket 0.4.5. Therefore, we do not have a Rocket 0.5 crate yet.

Modify The main.rs To Use Rocket 0.5 Compatible Codes

The following codes are sample codes from the Rocket GitHub repository URL.

If we use codes example from Rocket 0.4.5 (via crates.io), they will not compile.

Rust Rocket 0.4.5 Crate

Test Rust Stable And Rocket 0.5 (Latest Development Codes)

To test our codes, run the main.rs  file within the IDE. We get the following output on the console.

Then, open and web browser and try the following URL – http://localhost:8000/hello/karl/24. We get to the next page.

Since Rocket 0.5 release is not yet available officially, there may still be changes to the codebase. It is best to postpone any plans of migrating codes that rely on Rocket 0.4.5 and Rust nightly until we get the 0.5 release version.

This post is part of the Rust Programming Language For Beginners Tutorial.

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like