diff --git a/examples/raw.rs b/examples/raw.rs index da1ab3c3..02beb257 100644 --- a/examples/raw.rs +++ b/examples/raw.rs @@ -35,7 +35,7 @@ fn main() -> Result<()> { // When we first create a client we receive a `Connect` structure which must be resolved before // the client is actually connected and usable. - let unconnnected_client = Client::new(&config); + let unconnnected_client = Client::new(config); let client = unconnnected_client.wait()?; // Requests are created from the connected client. These calls return structures which diff --git a/examples/transaction.rs b/examples/transaction.rs index 2362470d..cad8c73c 100644 --- a/examples/transaction.rs +++ b/examples/transaction.rs @@ -84,7 +84,7 @@ fn main() { Config::new(args.pd) }; - let txn = Client::new(&config) + let txn = Client::new(config) .wait() .expect("Could not connect to tikv"); diff --git a/src/lib.rs b/src/lib.rs index 5a12bb42..590589da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,7 +101,7 @@ //! ]).with_security("root.ca", "internal.cert", "internal.key"); //! //! // Get an unresolved connection. -//! let connect = Client::new(&config); +//! let connect = Client::new(config); //! //! // Resolve the connection into a client. //! let client = connect.wait(); diff --git a/src/raw.rs b/src/raw.rs index d489f6c3..e78cc963 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -41,12 +41,12 @@ impl Client { /// ```rust,no_run /// use tikv_client::{Config, raw::Client}; /// use futures::Future; - /// let connect = Client::new(&Config::default()); + /// let connect = Client::new(Config::default()); /// let client = connect.wait(); /// ``` #[cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))] - pub fn new(config: &Config) -> Connect { - Connect::new(config.clone()) + pub fn new(config: Config) -> Connect { + Connect::new(config) } #[inline] @@ -62,7 +62,7 @@ impl Client { /// ```rust,no_run /// # use tikv_client::{Value, Config, raw::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let key = "TiKV"; /// let req = connected_client.get(key); @@ -80,7 +80,7 @@ impl Client { /// ```rust,no_run /// # use tikv_client::{KvPair, Config, raw::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let keys = vec!["TiKV", "TiDB"]; /// let req = connected_client.batch_get(keys); @@ -100,7 +100,7 @@ impl Client { /// ```rust,no_run /// # use tikv_client::{Key, Value, Config, raw::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let key = "TiKV"; /// let val = "TiKV"; @@ -118,7 +118,7 @@ impl Client { /// ```rust,no_run /// # use tikv_client::{Error, Result, KvPair, Key, Value, Config, raw::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let kvpair1 = ("PD", "Go"); /// let kvpair2 = ("TiKV", "Rust"); @@ -140,7 +140,7 @@ impl Client { /// ```rust,no_run /// # use tikv_client::{Key, Config, raw::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let key = "TiKV"; /// let req = connected_client.delete(key); @@ -157,7 +157,7 @@ impl Client { /// ```rust,no_run /// # use tikv_client::{Config, raw::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let keys = vec!["TiKV", "TiDB"]; /// let req = connected_client.batch_delete(keys); @@ -177,7 +177,7 @@ impl Client { /// ```rust,no_run /// # use tikv_client::{KvPair, Config, raw::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let inclusive_range = "TiKV"..="TiDB"; /// let req = connected_client.scan(inclusive_range, 2); @@ -194,7 +194,7 @@ impl Client { /// ```rust,no_run /// # use tikv_client::{Key, Config, raw::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let inclusive_range1 = "TiDB"..="TiKV"; /// let inclusive_range2 = "TiKV"..="TiSpark"; @@ -223,7 +223,7 @@ impl Client { /// ```rust,no_run /// # use tikv_client::{Key, Config, raw::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let inclusive_range = "TiKV"..="TiDB"; /// let req = connected_client.delete_range(inclusive_range); @@ -242,7 +242,7 @@ impl Client { /// use tikv_client::{Config, raw::{Client, Connect}}; /// use futures::Future; /// -/// let connect: Connect = Client::new(&Config::default()); +/// let connect: Connect = Client::new(Config::default()); /// let client: Client = connect.wait().unwrap(); /// ``` pub struct Connect { diff --git a/src/transaction.rs b/src/transaction.rs index 381f2b82..71979b84 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -33,12 +33,12 @@ impl Client { /// ```rust,no_run /// use tikv_client::{Config, transaction::Client}; /// use futures::Future; - /// let connect = Client::new(&Config::default()); + /// let connect = Client::new(Config::default()); /// let client = connect.wait(); /// ``` #[cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))] - pub fn new(config: &Config) -> Connect { - Connect::new(config.clone()) + pub fn new(config: Config) -> Connect { + Connect::new(config) } /// Create a new [`Transaction`](struct.Transaction.html) using the timestamp from [`current_timestamp`](struct.Client.html#method.current_timestamp). @@ -48,7 +48,7 @@ impl Client { /// ```rust,no_run /// use tikv_client::{Config, transaction::Client}; /// use futures::Future; - /// let connect = Client::new(&Config::default()); + /// let connect = Client::new(Config::default()); /// let client = connect.wait().unwrap(); /// let transaction = client.begin(); /// // ... Issue some commands. @@ -64,7 +64,7 @@ impl Client { /// ```rust,no_run /// use tikv_client::{Config, transaction::Client}; /// use futures::Future; - /// let connect = Client::new(&Config::default()); + /// let connect = Client::new(Config::default()); /// let client = connect.wait().unwrap(); /// let timestamp = client.current_timestamp(); /// let transaction = client.begin_with_timestamp(timestamp); @@ -81,7 +81,7 @@ impl Client { /// ```rust,no_run /// use tikv_client::{Config, transaction::Client}; /// use futures::Future; - /// let connect = Client::new(&Config::default()); + /// let connect = Client::new(Config::default()); /// let client = connect.wait().unwrap(); /// let snapshot = client.snapshot(); /// // ... Issue some commands. @@ -95,7 +95,7 @@ impl Client { /// ```rust,no_run /// use tikv_client::{Config, transaction::Client}; /// use futures::Future; - /// let connect = Client::new(&Config::default()); + /// let connect = Client::new(Config::default()); /// let client = connect.wait().unwrap(); /// let timestamp = client.current_timestamp(); /// ``` @@ -112,7 +112,7 @@ impl Client { /// use tikv_client::{Config, transaction::{Client, Connect}}; /// use futures::Future; /// -/// let connect: Connect = Client::new(&Config::default()); +/// let connect: Connect = Client::new(Config::default()); /// let client: Client = connect.wait().unwrap(); /// ``` pub struct Connect { @@ -187,7 +187,7 @@ impl Transaction { /// ```rust,no_run /// use tikv_client::{Config, transaction::Client}; /// use futures::Future; - /// let connect = Client::new(&Config::default()); + /// let connect = Client::new(Config::default()); /// let client = connect.wait().unwrap(); /// let txn = client.begin(); /// ``` @@ -202,7 +202,7 @@ impl Transaction { /// ```rust,no_run /// # use tikv_client::{Config, transaction::Client}; /// # use futures::Future; - /// # let connect = Client::new(&Config::default()); + /// # let connect = Client::new(Config::default()); /// # let connected_client = connect.wait().unwrap(); /// let txn = connected_client.begin(); /// // ... Do some actions. @@ -218,7 +218,7 @@ impl Transaction { /// ```rust,no_run /// # use tikv_client::{Config, transaction::Client}; /// # use futures::Future; - /// # let connect = Client::new(&Config::default()); + /// # let connect = Client::new(Config::default()); /// # let connected_client = connect.wait().unwrap(); /// let txn = connected_client.begin(); /// // ... Do some actions. @@ -234,7 +234,7 @@ impl Transaction { /// ```rust,no_run /// # use tikv_client::{Config, transaction::Client}; /// # use futures::Future; - /// # let connect = Client::new(&Config::default()); + /// # let connect = Client::new(Config::default()); /// # let connected_client = connect.wait().unwrap(); /// let mut txn = connected_client.begin(); /// // ... Do some actions. @@ -254,7 +254,7 @@ impl Transaction { /// ```rust,no_run /// # use tikv_client::{Config, transaction::{Client, Timestamp}}; /// # use futures::Future; - /// # let connect = Client::new(&Config::default()); + /// # let connect = Client::new(Config::default()); /// # let connected_client = connect.wait().unwrap(); /// let txn = connected_client.begin(); /// // ... Do some actions. @@ -269,7 +269,7 @@ impl Transaction { /// ```rust,no_run /// # use tikv_client::{Config, transaction::{Client, Snapshot}}; /// # use futures::Future; - /// # let connect = Client::new(&Config::default()); + /// # let connect = Client::new(Config::default()); /// # let connected_client = connect.wait().unwrap(); /// let txn = connected_client.begin(); /// // ... Do some actions. @@ -284,7 +284,7 @@ impl Transaction { /// ```rust,no_run /// # use tikv_client::{Config, transaction::{Client, IsolationLevel}}; /// # use futures::Future; - /// # let connect = Client::new(&Config::default()); + /// # let connect = Client::new(Config::default()); /// # let connected_client = connect.wait().unwrap(); /// let mut txn = connected_client.begin(); /// txn.set_isolation_level(IsolationLevel::SnapshotIsolation); @@ -301,7 +301,7 @@ impl Transaction { /// ```rust,no_run /// # use tikv_client::{Value, Config, transaction::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let mut txn = connected_client.begin(); /// let key = "TiKV"; @@ -322,7 +322,7 @@ impl Transaction { /// ```rust,no_run /// # use tikv_client::{KvPair, Config, transaction::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let mut txn = connected_client.begin(); /// let keys = vec!["TiKV", "TiDB"]; @@ -350,7 +350,7 @@ impl Transaction { /// ```rust,no_run /// # use tikv_client::{Key, Value, Config, transaction::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let mut txn = connected_client.begin(); /// let key = "TiKV"; @@ -371,7 +371,7 @@ impl Transaction { /// ```rust,no_run /// # use tikv_client::{Key, Config, transaction::Client}; /// # use futures::Future; - /// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"])); + /// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.wait().unwrap(); /// let mut txn = connected_client.begin(); /// let key = "TiKV"; diff --git a/tests/integration_tests/raw.rs b/tests/integration_tests/raw.rs index 06e78ce6..19c446d7 100644 --- a/tests/integration_tests/raw.rs +++ b/tests/integration_tests/raw.rs @@ -35,7 +35,7 @@ fn wipe_all(client: &Client) { } fn connect() -> Client { - let client = Client::new(&Config::new(pd_addr())) + let client = Client::new(Config::new(pd_addr())) .wait() .expect("Could not connect to tikv"); wipe_all(&client);