Clean up comments on named parameter methods

This commit is contained in:
John Gallagher 2015-12-10 20:30:05 -05:00
parent 7338f23d4b
commit 21528452d7

View File

@ -10,12 +10,15 @@ use types::ToSql;
impl SqliteConnection { impl SqliteConnection {
/// Convenience method to prepare and execute a single SQL statement with named parameter(s). /// Convenience method to prepare and execute a single SQL statement with named parameter(s).
/// ///
/// On success, returns the number of rows that were changed or inserted or deleted (via
/// `sqlite3_changes`).
///
/// ## Example /// ## Example
/// ///
/// ```rust,no_run /// ```rust,no_run
/// # use rusqlite::{SqliteConnection, SqliteResult}; /// # use rusqlite::{SqliteConnection, SqliteResult};
/// fn insert(conn: &SqliteConnection) -> SqliteResult<i32> { /// fn insert(conn: &SqliteConnection) -> SqliteResult<i32> {
/// conn.execute_named("INSERT INTO test (id, name, flag) VALUES (:id, :name, :flag)", &[(":name", &"one")]) /// conn.execute_named("INSERT INTO test (name) VALUES (:name)", &[(":name", &"one")])
/// } /// }
/// ``` /// ```
/// ///
@ -27,7 +30,8 @@ impl SqliteConnection {
self.prepare(sql).and_then(|mut stmt| stmt.execute_named(params)) self.prepare(sql).and_then(|mut stmt| stmt.execute_named(params))
} }
/// Convenience method to execute a query with named parameter(s) that is expected to return a single row. /// Convenience method to execute a query with named parameter(s) that is expected to return
/// a single row.
/// ///
/// If the query returns more than one row, all rows except the first are ignored. /// If the query returns more than one row, all rows except the first are ignored.
/// ///
@ -75,7 +79,7 @@ impl<'conn> SqliteStatement<'conn> {
/// ///
/// # Failure /// # Failure
/// ///
/// Return None if `name` is invalid (NulError) or if no matching parameter is found. /// Return None if `name` is invalid or if no matching parameter is found.
pub fn parameter_index(&self, name: &str) -> Option<i32> { pub fn parameter_index(&self, name: &str) -> Option<i32> {
unsafe { unsafe {
CString::new(name).ok().and_then(|c_name| { CString::new(name).ok().and_then(|c_name| {
@ -98,8 +102,8 @@ impl<'conn> SqliteStatement<'conn> {
/// ```rust,no_run /// ```rust,no_run
/// # use rusqlite::{SqliteConnection, SqliteResult}; /// # use rusqlite::{SqliteConnection, SqliteResult};
/// fn insert(conn: &SqliteConnection) -> SqliteResult<i32> { /// fn insert(conn: &SqliteConnection) -> SqliteResult<i32> {
/// let mut stmt = try!(conn.prepare("INSERT INTO test (id, name, flag) VALUES (:id, :name, :flag)")); /// let mut stmt = try!(conn.prepare("INSERT INTO test (name) VALUES (:name)"));
/// return stmt.execute_named(&[(":name", &"one")]); /// stmt.execute_named(&[(":name", &"one")])
/// } /// }
/// ``` /// ```
/// ///
@ -114,7 +118,8 @@ impl<'conn> SqliteStatement<'conn> {
} }
} }
/// Execute the prepared statement with named parameter(s), returning an iterator over the resulting rows. /// Execute the prepared statement with named parameter(s), returning an iterator over the
/// resulting rows.
/// ///
/// ## Example /// ## Example
/// ///
@ -126,7 +131,7 @@ impl<'conn> SqliteStatement<'conn> {
/// for row in rows { /// for row in rows {
/// // ... /// // ...
/// } /// }
/// return Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
/// ///