Upgrade to 2018 Edition (#7)

* Bump to 2018 edition.

Signed-off-by: Hoverbear <operator@hoverbear.org>

* Add toolchain

Signed-off-by: Hoverbear <operator@hoverbear.org>

* Fix examples

Signed-off-by: Hoverbear <operator@hoverbear.org>

* fmt and lint

Signed-off-by: Hoverbear <operator@hoverbear.org>

* We can use stable now

Signed-off-by: Hoverbear <operator@hoverbear.org>
This commit is contained in:
A. Hobden 2018-12-23 07:28:02 -08:00 committed by GitHub
parent ce6b36ada5
commit 5ed332709e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 42 deletions

View File

@ -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"

View File

@ -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() {

View File

@ -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<Item = impl Into<KvPair>>) {
let mut txn = client.begin();
@ -28,7 +26,8 @@ fn puts(client: &Client, pairs: impl IntoIterator<Item = impl Into<KvPair>>) {
.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<Key>, 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<Item = Key>) {
.into_iter()
.map(|p| {
txn.delete(p).wait().expect("Could not delete key");
}).collect();
})
.collect();
txn.commit().wait().expect("Could not commit transaction");
}

1
rust-toolchain Normal file
View File

@ -0,0 +1 @@
stable

View File

@ -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())

View File

@ -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<u8>);

View File

@ -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())
}

View File

@ -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())
}