Skip to content

Commit

Permalink
docs: simplify helloworld-tutorial (#1369)
Browse files Browse the repository at this point in the history
- Remove the `hello_world` crate prefix, `HelloReply` is imported directly.
- Remove useless calls to `into()`:

error: useless conversion to the same type: `std::string::String`
  --> src/main.rs:18:22
   |
18 |             message: format!("Hello {}!", request.into_inner().name).into(),
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}!", request.into_inner().name)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
   = note: `-D clippy::useless-conversion` implied by `-D warnings`

Co-authored-by: tottoto <tottotodev@gmail.com>
  • Loading branch information
punkeel and tottoto committed May 31, 2024
1 parent d1dbd03 commit d9fa673
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/helloworld-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl Greeter for MyGreeter {
) -> Result<Response<HelloReply>, Status> { // Return an instance of type HelloReply
println!("Got a request: {:?}", request);

let reply = hello_world::HelloReply {
let reply = HelloReply {
message: format!("Hello {}!", request.into_inner().name), // We must use .into_inner() as the fields of gRPC requests and responses are private
};

Expand Down Expand Up @@ -215,7 +215,7 @@ impl Greeter for MyGreeter {
) -> Result<Response<HelloReply>, Status> {
println!("Got a request: {:?}", request);

let reply = hello_world::HelloReply {
let reply = HelloReply {
message: format!("Hello {}!", request.into_inner().name),
};

Expand Down

0 comments on commit d9fa673

Please sign in to comment.