From b7efb37b3542522247a6a9da037889cd3d947cfc Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Tue, 8 Sep 2015 18:06:41 +1000 Subject: [PATCH] Relax uses of `P: AsRef<...>` from `&P` to `P`. This means that one can pass `AsRef` types directly, without having to insert a `&`, e.g. `SqliteConnection::open("foo.db")` (new) vs. `SqliteConnection::open(&"foo.db")` (old). This should be backwards compatible, since there is an impl in the standard library: impl<'a, T, U> AsRef for &'a T where U: ?Sized, T: AsRef + ?Sized I.e. the old `&P` satisfies the new bound still. (Taking `P` directly is what the standard library does with similar functions, like `File::open`.) --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f98780b..0814ecb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -160,7 +160,7 @@ impl SqliteConnection { /// /// `SqliteConnection::open(path)` is equivalent to `SqliteConnection::open_with_flags(path, /// SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE)`. - pub fn open>(path: &P) -> SqliteResult { + pub fn open>(path: P) -> SqliteResult { let flags = Default::default(); SqliteConnection::open_with_flags(path, flags) } @@ -175,7 +175,7 @@ impl SqliteConnection { /// /// Database Connection](http://www.sqlite.org/c3ref/open.html) for a description of valid /// flag combinations. - pub fn open_with_flags>(path: &P, flags: SqliteOpenFlags) + pub fn open_with_flags>(path: P, flags: SqliteOpenFlags) -> SqliteResult { let c_path = try!(path_to_cstring(path.as_ref())); InnerSqliteConnection::open_with_flags(&c_path, flags).map(|db| { @@ -393,10 +393,10 @@ impl SqliteConnection { /// fn load_my_extension(conn: &SqliteConnection) -> SqliteResult<()> { /// let _guard = try!(SqliteLoadExtensionGuard::new(conn)); /// - /// conn.load_extension(Path::new("my_sqlite_extension"), None) + /// conn.load_extension("my_sqlite_extension", None) /// } #[cfg(feature = "load_extension")] - pub fn load_extension>(&self, dylib_path: &P, entry_point: Option<&str>) -> SqliteResult<()> { + pub fn load_extension>(&self, dylib_path: P, entry_point: Option<&str>) -> SqliteResult<()> { self.db.borrow_mut().load_extension(dylib_path, entry_point) }