Repository: aisk/rust-memcache (language: rust)

Issue:
Adding top leven connect function
I think this is more convenient for user when using `memcache::connect` instead of `memcache::Client::client`.


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index 16a8f0a..82dfef7 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ memcache = "*"
 
 ```rust
 // create connection with to memcached server node:
-let client = memcache::Client::connect("memcache://127.0.0.1:12345?timeout=10&tcp_nodelay=true").unwrap();
+let client = memcache::connect("memcache://127.0.0.1:12345?timeout=10&tcp_nodelay=true").unwrap();
 
 // flush the database
 client.flush().unwrap();
@@ -79,7 +79,7 @@ If you have multiple memcached server, you can create the `memcache::Client` str
 This library have a basic rule to do this with rust's builtin hash function, and also you can use your custom function to do this, for something like you can using a have more data on one server which have more memory quota, or cluster keys with their prefix, or using consitent hash for large memcached cluster.
 
 ```rust
-let mut client = memcache::Client::connect(vec!["memcache://127.0.0.1:12345", "memcache:///tmp/memcached.sock"]).unwrap();
+let mut client = memcache::connect(vec!["memcache://127.0.0.1:12345", "memcache:///tmp/memcached.sock"]).unwrap();
 client.hash_function = |key: &str| -> u64 {
     // your custom hashing function here
     return 1;
diff --git a/src/lib.rs b/src/lib.rs
index 12836a5..20ffcc9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -33,7 +33,7 @@ memcache = "*"
 
 ```rust
 // create connection with to memcached server node:
-let client = memcache::Client::connect("memcache://127.0.0.1:12345?timeout=10&tcp_nodelay=true").unwrap();
+let client = memcache::connect("memcache://127.0.0.1:12345?timeout=10&tcp_nodelay=true").unwrap();
 
 // flush the database:
 client.flush().unwrap();
@@ -82,3 +82,14 @@ mod value;
 pub use client::{Client, Connectable};
 pub use error::{ClientError, CommandError, MemcacheError, ServerError};
 pub use value::{FromMemcacheValue, FromMemcacheValueExt, ToMemcacheValue};
+
+/// Create a memcached client instance and connect to memcached server.
+///
+/// Example:
+///
+/// ```rust
+/// let client = memcache::connect("memcache://localhost:12345").unwrap();
+/// ```
+pub fn connect<C: Connectable>(target: C) -> Result<Client, MemcacheError> {
+    Client::connect(target)
+}


Test patch: