From fc6451935cbb6ab8037773f210ce15a45be7e79b Mon Sep 17 00:00:00 2001 From: Ikram Khan Date: Wed, 8 Jan 2025 20:42:13 +0600 Subject: [PATCH] Remove extraneous `use` statement (#4193) In Listing 14-7 of Chapter 14, the `use add_one;` statement is redundant and can be removed. Before the Rust 2018 edition, this statement was required to bring the `add_one` crate into scope, so it likely got missed during refactorings from that transition. By removing this line, the code becomes more concise and reflects the current best practices for using external crates in Rust. Issue #4186 --------- Co-authored-by: Chris Krycho --- .../listing-14-07/add/adder/src/main.rs | 2 -- src/ch14-03-cargo-workspaces.md | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/listings/ch14-more-about-cargo/listing-14-07/add/adder/src/main.rs b/listings/ch14-more-about-cargo/listing-14-07/add/adder/src/main.rs index 1316294909..ead4e1dd83 100644 --- a/listings/ch14-more-about-cargo/listing-14-07/add/adder/src/main.rs +++ b/listings/ch14-more-about-cargo/listing-14-07/add/adder/src/main.rs @@ -1,5 +1,3 @@ -use add_one; - fn main() { let num = 10; println!("Hello, world! {num} plus one is {}!", add_one::add_one(num)); diff --git a/src/ch14-03-cargo-workspaces.md b/src/ch14-03-cargo-workspaces.md index ccbae71463..feae08f65d 100644 --- a/src/ch14-03-cargo-workspaces.md +++ b/src/ch14-03-cargo-workspaces.md @@ -149,11 +149,10 @@ Cargo doesn’t assume that crates in a workspace will depend on each other, so we need to be explicit about the dependency relationships. Next, let’s use the `add_one` function (from the `add_one` crate) in the -`adder` crate. Open the _adder/src/main.rs_ file and add a `use` line at the -top to bring the new `add_one` library crate into scope. Then change the `main` +`adder` crate. Open the _adder/src/main.rs_ file and change the `main` function to call the `add_one` function, as in Listing 14-7. -+ ```rust,ignore {{#rustdoc_include ../listings/ch14-more-about-cargo/listing-14-07/add/adder/src/main.rs}}