diff --git a/Cargo.toml b/Cargo.toml index 1f48182..344150b 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" diff --git a/examples/raw.rs b/examples/raw.rs index c8bfbdf..403c1e7 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 3c77c07..23a1e28 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"); } diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..870bbe4 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +stable \ No newline at end of file diff --git a/src/errors.rs b/src/errors.rs index a8d8148..66a9a20 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::error; -use std::result; +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) { @@ -22,7 +23,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 1827b26..3589dc8 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 serde_derive::*; +use std::ops::Deref; +use std::path::PathBuf; 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 0bad042..5e97d17 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 crate::{Config, Error, Key, KvPair, Value}; use futures::{Future, Poll}; - -use {Config, Error, Key, KvPair, Value}; +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))] + #![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 ffa4021..1b650d8 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 crate::{Config, Error, Key, KvPair, Value}; use futures::{Future, Poll, Stream}; - -use {Config, Error, Key, KvPair, Value}; +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))] + #![allow(clippy::new_ret_no_self)] pub fn new(config: &Config) -> Connect { Connect::new(config.clone()) }