Skip to content

Commit 5ed3327

Browse files
authored
Upgrade to 2018 Edition (#7)
* Bump to 2018 edition. Signed-off-by: Hoverbear <[email protected]> * Add toolchain Signed-off-by: Hoverbear <[email protected]> * Fix examples Signed-off-by: Hoverbear <[email protected]> * fmt and lint Signed-off-by: Hoverbear <[email protected]> * We can use stable now Signed-off-by: Hoverbear <[email protected]>
1 parent ce6b36a commit 5ed3327

File tree

8 files changed

+32
-42
lines changed

8 files changed

+32
-42
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ license = "Apache-2.0"
66
authors = ["The TiKV Project Authors"]
77
repository = "https://github.com/tikv/client-rust"
88
description = "The rust language implementation of TiKV client."
9+
edition = "2018"
910

1011
[lib]
1112
name = "tikv_client"

examples/raw.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
extern crate futures;
15-
extern crate tikv_client;
16-
17-
use std::path::PathBuf;
18-
1914
use futures::future::Future;
15+
use std::path::PathBuf;
2016
use tikv_client::*;
2117

2218
fn main() {

examples/transaction.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
extern crate futures;
15-
extern crate tikv_client;
16-
14+
use futures::{future, Future, Stream};
1715
use std::ops::RangeBounds;
1816
use std::path::PathBuf;
19-
20-
use futures::{future, Future, Stream};
21-
use tikv_client::transaction::{Client, IsolationLevel};
22-
use tikv_client::*;
17+
use tikv_client::{
18+
transaction::{Client, IsolationLevel},
19+
Config, Key, KvPair, Value,
20+
};
2321

2422
fn puts(client: &Client, pairs: impl IntoIterator<Item = impl Into<KvPair>>) {
2523
let mut txn = client.begin();
@@ -28,7 +26,8 @@ fn puts(client: &Client, pairs: impl IntoIterator<Item = impl Into<KvPair>>) {
2826
.into_iter()
2927
.map(Into::into)
3028
.map(|p| txn.set(p.key().clone(), p.value().clone())),
31-
).wait()
29+
)
30+
.wait()
3231
.expect("Could not set key value pairs");
3332
txn.commit().wait().expect("Could not commit transaction");
3433
}
@@ -49,10 +48,12 @@ fn scan(client: &Client, range: impl RangeBounds<Key>, mut limit: usize) {
4948
limit -= 1;
5049
true
5150
})
52-
}).for_each(|pair| {
51+
})
52+
.for_each(|pair| {
5353
println!("{:?}", pair);
5454
Ok(())
55-
}).wait()
55+
})
56+
.wait()
5657
.expect("Could not scan keys");
5758
}
5859

@@ -63,7 +64,8 @@ fn dels(client: &Client, keys: impl IntoIterator<Item = Key>) {
6364
.into_iter()
6465
.map(|p| {
6566
txn.delete(p).wait().expect("Could not delete key");
66-
}).collect();
67+
})
68+
.collect();
6769
txn.commit().wait().expect("Could not commit transaction");
6870
}
6971

rust-toolchain

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
stable

src/errors.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
use std::error;
15-
use std::result;
14+
use grpcio;
15+
use quick_error::quick_error;
16+
use std::{error, result};
1617

17-
quick_error!{
18+
quick_error! {
1819
#[derive(Debug)]
1920
pub enum Error {
2021
Io(err: ::std::io::Error) {
2122
from()
2223
cause(err)
2324
description(err.description())
2425
}
25-
Grpc(err: ::grpc::Error) {
26+
Grpc(err: grpcio::Error) {
2627
from()
2728
cause(err)
2829
description(err.description())

src/lib.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,16 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
extern crate futures;
15-
extern crate serde;
16-
#[macro_use]
17-
extern crate serde_derive;
18-
#[macro_use]
19-
extern crate quick_error;
20-
extern crate grpcio as grpc;
14+
use serde_derive::*;
15+
use std::ops::Deref;
16+
use std::path::PathBuf;
2117

2218
pub mod errors;
2319
pub mod raw;
2420
pub mod transaction;
2521

26-
use std::ops::Deref;
27-
use std::path::PathBuf;
28-
29-
pub use errors::Error;
30-
pub use errors::Result;
22+
pub use crate::errors::Error;
23+
pub use crate::errors::Result;
3124

3225
#[derive(Default, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
3326
pub struct Key(Vec<u8>);

src/raw.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
use std::ops::RangeBounds;
15-
14+
use crate::{Config, Error, Key, KvPair, Value};
1615
use futures::{Future, Poll};
17-
18-
use {Config, Error, Key, KvPair, Value};
16+
use std::ops::RangeBounds;
1917

2018
#[derive(Default, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
2119
pub struct ColumnFamily(String);
@@ -388,7 +386,7 @@ impl Future for Connect {
388386
pub struct Client;
389387

390388
impl Client {
391-
#![cfg_attr(feature = "cargo-clippy", allow(new_ret_no_self))]
389+
#![allow(clippy::new_ret_no_self)]
392390
pub fn new(config: &Config) -> Connect {
393391
Connect::new(config.clone())
394392
}

src/transaction.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
use std::ops::RangeBounds;
15-
14+
use crate::{Config, Error, Key, KvPair, Value};
1615
use futures::{Future, Poll, Stream};
17-
18-
use {Config, Error, Key, KvPair, Value};
16+
use std::ops::RangeBounds;
1917

2018
#[derive(Copy, Clone)]
2119
pub struct Timestamp(u64);
@@ -302,7 +300,7 @@ impl Future for Connect {
302300
pub struct Client {}
303301

304302
impl Client {
305-
#![cfg_attr(feature = "cargo-clippy", allow(new_ret_no_self))]
303+
#![allow(clippy::new_ret_no_self)]
306304
pub fn new(config: &Config) -> Connect {
307305
Connect::new(config.clone())
308306
}

0 commit comments

Comments
 (0)