summaryrefslogtreecommitdiff
path: root/tutorial/rs
diff options
context:
space:
mode:
authorAllen George <allengeorge@apache.org>2020-11-08 09:51:19 -0500
committerAllen George <allengeorge@apache.org>2020-11-12 08:47:42 -0500
commit7ddbcc07ec98349da59bb023d0fed8db37097c18 (patch)
tree80a46fb7f940e8626bfd8f38346f0b85cce368a7 /tutorial/rs
parent22671db01f5c349f2fa54b393581cb4d61bdd895 (diff)
downloadthrift-7ddbcc07ec98349da59bb023d0fed8db37097c18.tar.gz
THRIFT-5306: Rust code and generated code no longer has clippy warnings (Rust 1.40)
Client: rs NOTE: Also properly update the min/max supported Rust versions
Diffstat (limited to 'tutorial/rs')
-rw-r--r--tutorial/rs/Cargo.toml2
-rw-r--r--tutorial/rs/README.md25
-rw-r--r--tutorial/rs/src/bin/tutorial_client.rs3
-rw-r--r--tutorial/rs/src/bin/tutorial_server.rs7
4 files changed, 9 insertions, 28 deletions
diff --git a/tutorial/rs/Cargo.toml b/tutorial/rs/Cargo.toml
index d8e2a9a8d..5e21d51a6 100644
--- a/tutorial/rs/Cargo.toml
+++ b/tutorial/rs/Cargo.toml
@@ -9,8 +9,6 @@ publish = false
[dependencies]
clap = "2.33"
-ordered-float = "1.0"
-try_from = "0.3"
[dependencies.thrift]
path = "../../lib/rs"
diff --git a/tutorial/rs/README.md b/tutorial/rs/README.md
index 166854bea..97b1490fe 100644
--- a/tutorial/rs/README.md
+++ b/tutorial/rs/README.md
@@ -4,37 +4,22 @@
1. Get the [Thrift compiler](https://thrift.apache.org).
-2. Add the following crates to your `Cargo.toml`.
+2. Add the thrift crate to your `Cargo.toml`.
```toml
thrift = "x.y.z" # x.y.z is the version of the thrift compiler
-ordered-float = "0.3.0"
-try_from = "0.2.0"
```
-3. Add the same crates to your `lib.rs` or `main.rs`.
-
-```rust
-extern crate ordered_float;
-extern crate thrift;
-extern crate try_from;
-```
-
-4. Generate Rust sources for your IDL (for example, `Tutorial.thrift`).
+3. Generate Rust sources for your IDL (for example, `Tutorial.thrift`).
```shell
thrift -out my_rust_program/src --gen rs -r Tutorial.thrift
```
-5. Use the generated source in your code.
+4. Use the generated source in your code.
```rust
-// add extern crates here, or in your lib.rs
-extern crate ordered_float;
-extern crate thrift;
-extern crate try_from;
-
-// generated Rust module
+// generated Rust module from Thrift IDL
mod tutorial;
use thrift::protocol::{TCompactInputProtocol, TCompactOutputProtocol};
@@ -120,7 +105,7 @@ each generated file.
### Results and Errors
The Thrift runtime library defines a `thrift::Result` and a `thrift::Error` type,
-both of which are used throught the runtime library and in all generated code.
+both of which are used throughout the runtime library and in all generated code.
Conversions are defined from `std::io::Error`, `str` and `String` into
`thrift::Error`.
diff --git a/tutorial/rs/src/bin/tutorial_client.rs b/tutorial/rs/src/bin/tutorial_client.rs
index 90a26d811..f7de23f06 100644
--- a/tutorial/rs/src/bin/tutorial_client.rs
+++ b/tutorial/rs/src/bin/tutorial_client.rs
@@ -15,8 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#[macro_use]
-extern crate clap;
+use clap::{clap_app, value_t};
use thrift::protocol::{TCompactInputProtocol, TCompactOutputProtocol};
use thrift::transport::{
diff --git a/tutorial/rs/src/bin/tutorial_server.rs b/tutorial/rs/src/bin/tutorial_server.rs
index e4d1d2ecb..fbccb69c9 100644
--- a/tutorial/rs/src/bin/tutorial_server.rs
+++ b/tutorial/rs/src/bin/tutorial_server.rs
@@ -15,18 +15,17 @@
// specific language governing permissions and limitations
// under the License.
-#[macro_use]
-extern crate clap;
-
use std::collections::HashMap;
use std::convert::{From, Into};
use std::default::Default;
use std::sync::Mutex;
+use clap::{clap_app, value_t};
+
use thrift::protocol::{TCompactInputProtocolFactory, TCompactOutputProtocolFactory};
use thrift::server::TServer;
-
use thrift::transport::{TFramedReadTransportFactory, TFramedWriteTransportFactory};
+
use thrift_tutorial::shared::{SharedServiceSyncHandler, SharedStruct};
use thrift_tutorial::tutorial::{CalculatorSyncHandler, CalculatorSyncProcessor};
use thrift_tutorial::tutorial::{InvalidOperation, Operation, Work};