From 414d0fc415d5345ed0e231f7378ec9fd12cfa3b0 Mon Sep 17 00:00:00 2001 From: Hoverbear Date: Mon, 19 Nov 2018 09:09:10 -0800 Subject: [PATCH 1/5] Bump to 2018 edition. Signed-off-by: Hoverbear --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 1f481829..344150b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ license = "Apache-2.0" authors = ["The TiKV Project Authors"] repository = "https://github.com/tikv/client-rust" description = "The rust language implementation of TiKV client." +edition = "2018" [lib] name = "tikv_client" From a7242ed0c5d8a26b02690e1b2960b7ed43e1703a Mon Sep 17 00:00:00 2001 From: Hoverbear Date: Mon, 19 Nov 2018 09:17:43 -0800 Subject: [PATCH 2/5] Add toolchain Signed-off-by: Hoverbear --- rust-toolchain | 4 ++++ src/errors.rs | 4 +++- src/lib.rs | 17 +++++------------ src/raw.rs | 2 +- src/transaction.rs | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 rust-toolchain diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 00000000..f22b1d64 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1,4 @@ +nightly + +# We explicitly use nightly for the moment even though we target stable so we +# can develop for the 2018 edition. \ No newline at end of file diff --git a/src/errors.rs b/src/errors.rs index a8d81488..59ced9bd 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -11,6 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use quick_error::quick_error; +use grpcio; use std::error; use std::result; @@ -22,7 +24,7 @@ quick_error!{ cause(err) description(err.description()) } - Grpc(err: ::grpc::Error) { + Grpc(err: grpcio::Error) { from() cause(err) description(err.description()) diff --git a/src/lib.rs b/src/lib.rs index 1827b26d..89db422e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,23 +11,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -extern crate futures; -extern crate serde; -#[macro_use] -extern crate serde_derive; -#[macro_use] -extern crate quick_error; -extern crate grpcio as grpc; +use std::ops::Deref; +use std::path::PathBuf; +use serde_derive::*; pub mod errors; pub mod raw; pub mod transaction; -use std::ops::Deref; -use std::path::PathBuf; - -pub use errors::Error; -pub use errors::Result; +pub use crate::errors::Error; +pub use crate::errors::Result; #[derive(Default, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] pub struct Key(Vec); diff --git a/src/raw.rs b/src/raw.rs index 0bad042d..62ef5a6e 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -15,7 +15,7 @@ use std::ops::RangeBounds; use futures::{Future, Poll}; -use {Config, Error, Key, KvPair, Value}; +use crate::{Config, Error, Key, KvPair, Value}; #[derive(Default, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] pub struct ColumnFamily(String); diff --git a/src/transaction.rs b/src/transaction.rs index ffa4021b..abe219e8 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -15,7 +15,7 @@ use std::ops::RangeBounds; use futures::{Future, Poll, Stream}; -use {Config, Error, Key, KvPair, Value}; +use crate::{Config, Error, Key, KvPair, Value}; #[derive(Copy, Clone)] pub struct Timestamp(u64); From 842d85cbf391a01722bc139ae76b2e4776c39dc1 Mon Sep 17 00:00:00 2001 From: Hoverbear Date: Mon, 19 Nov 2018 09:22:25 -0800 Subject: [PATCH 3/5] Fix examples Signed-off-by: Hoverbear --- examples/raw.rs | 6 +----- examples/transaction.rs | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/examples/raw.rs b/examples/raw.rs index c8bfbdfc..403c1e79 100644 --- a/examples/raw.rs +++ b/examples/raw.rs @@ -11,12 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -extern crate futures; -extern crate tikv_client; - -use std::path::PathBuf; - use futures::future::Future; +use std::path::PathBuf; use tikv_client::*; fn main() { diff --git a/examples/transaction.rs b/examples/transaction.rs index 3c77c070..23a1e285 100644 --- a/examples/transaction.rs +++ b/examples/transaction.rs @@ -11,15 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -extern crate futures; -extern crate tikv_client; - +use futures::{future, Future, Stream}; use std::ops::RangeBounds; use std::path::PathBuf; - -use futures::{future, Future, Stream}; -use tikv_client::transaction::{Client, IsolationLevel}; -use tikv_client::*; +use tikv_client::{ + transaction::{Client, IsolationLevel}, + Config, Key, KvPair, Value, +}; fn puts(client: &Client, pairs: impl IntoIterator>) { let mut txn = client.begin(); @@ -28,7 +26,8 @@ fn puts(client: &Client, pairs: impl IntoIterator>) { .into_iter() .map(Into::into) .map(|p| txn.set(p.key().clone(), p.value().clone())), - ).wait() + ) + .wait() .expect("Could not set key value pairs"); txn.commit().wait().expect("Could not commit transaction"); } @@ -49,10 +48,12 @@ fn scan(client: &Client, range: impl RangeBounds, mut limit: usize) { limit -= 1; true }) - }).for_each(|pair| { + }) + .for_each(|pair| { println!("{:?}", pair); Ok(()) - }).wait() + }) + .wait() .expect("Could not scan keys"); } @@ -63,7 +64,8 @@ fn dels(client: &Client, keys: impl IntoIterator) { .into_iter() .map(|p| { txn.delete(p).wait().expect("Could not delete key"); - }).collect(); + }) + .collect(); txn.commit().wait().expect("Could not commit transaction"); } From 8a4dd9e05760e9a71ae3f4a9df7b5d15e111f123 Mon Sep 17 00:00:00 2001 From: Hoverbear Date: Mon, 19 Nov 2018 09:23:55 -0800 Subject: [PATCH 4/5] fmt and lint Signed-off-by: Hoverbear --- src/errors.rs | 5 ++--- src/lib.rs | 2 +- src/raw.rs | 8 +++----- src/transaction.rs | 8 +++----- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 59ced9bd..e3e81c39 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -11,10 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -use quick_error::quick_error; use grpcio; -use std::error; -use std::result; +use quick_error::quick_error; +use std::{error, result}; quick_error!{ #[derive(Debug)] diff --git a/src/lib.rs b/src/lib.rs index 89db422e..3589dc89 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +use serde_derive::*; use std::ops::Deref; use std::path::PathBuf; -use serde_derive::*; pub mod errors; pub mod raw; diff --git a/src/raw.rs b/src/raw.rs index 62ef5a6e..93b2ee38 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::ops::RangeBounds; - -use futures::{Future, Poll}; - use crate::{Config, Error, Key, KvPair, Value}; +use futures::{Future, Poll}; +use std::ops::RangeBounds; #[derive(Default, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] pub struct ColumnFamily(String); @@ -388,7 +386,7 @@ impl Future for Connect { pub struct Client; impl Client { - #![cfg_attr(feature = "cargo-clippy", allow(new_ret_no_self))] + #![cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))] pub fn new(config: &Config) -> Connect { Connect::new(config.clone()) } diff --git a/src/transaction.rs b/src/transaction.rs index abe219e8..3db2ae53 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::ops::RangeBounds; - -use futures::{Future, Poll, Stream}; - use crate::{Config, Error, Key, KvPair, Value}; +use futures::{Future, Poll, Stream}; +use std::ops::RangeBounds; #[derive(Copy, Clone)] pub struct Timestamp(u64); @@ -302,7 +300,7 @@ impl Future for Connect { pub struct Client {} impl Client { - #![cfg_attr(feature = "cargo-clippy", allow(new_ret_no_self))] + #![cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))] pub fn new(config: &Config) -> Connect { Connect::new(config.clone()) } From 517503f428fdfb256fcc89f4c7d34daae3bb8e79 Mon Sep 17 00:00:00 2001 From: Hoverbear Date: Fri, 7 Dec 2018 10:10:21 -0800 Subject: [PATCH 5/5] We can use stable now Signed-off-by: Hoverbear --- rust-toolchain | 5 +---- src/errors.rs | 2 +- src/raw.rs | 2 +- src/transaction.rs | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index f22b1d64..870bbe4e 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1 @@ -nightly - -# We explicitly use nightly for the moment even though we target stable so we -# can develop for the 2018 edition. \ No newline at end of file +stable \ No newline at end of file diff --git a/src/errors.rs b/src/errors.rs index e3e81c39..66a9a20b 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -15,7 +15,7 @@ use grpcio; use quick_error::quick_error; use std::{error, result}; -quick_error!{ +quick_error! { #[derive(Debug)] pub enum Error { Io(err: ::std::io::Error) { diff --git a/src/raw.rs b/src/raw.rs index 93b2ee38..5e97d17b 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -386,7 +386,7 @@ impl Future for Connect { pub struct Client; impl Client { - #![cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))] + #![allow(clippy::new_ret_no_self)] pub fn new(config: &Config) -> Connect { Connect::new(config.clone()) } diff --git a/src/transaction.rs b/src/transaction.rs index 3db2ae53..1b650d8c 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -300,7 +300,7 @@ impl Future for Connect { pub struct Client {} impl Client { - #![cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))] + #![allow(clippy::new_ret_no_self)] pub fn new(config: &Config) -> Connect { Connect::new(config.clone()) }