From e6da9fd6f792852c41e675870a0b4254190892fc Mon Sep 17 00:00:00 2001 From: Ivan Ukhov Date: Sat, 13 Jun 2020 08:51:55 +0200 Subject: [PATCH] Rename count to column_count --- src/cursor.rs | 6 +++--- src/statement.rs | 10 +++++----- tests/lib.rs | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cursor.rs b/src/cursor.rs index b417bd5..3d9971f 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -22,8 +22,8 @@ impl<'l> Cursor<'l> { /// Return the number of columns. #[inline] - pub fn count(&self) -> usize { - self.statement.count() + pub fn column_count(&self) -> usize { + self.statement.column_count() } /// Advance to the next row and read all columns. @@ -44,7 +44,7 @@ impl<'l> Cursor<'l> { Some(values) } _ => { - let count = self.statement.count(); + let count = self.statement.column_count(); let mut values = Vec::with_capacity(count); for i in 0..count { values.push(self.statement.read(i)?); diff --git a/src/statement.rs b/src/statement.rs index abff1d1..8b5de21 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -51,7 +51,7 @@ impl<'l> Statement<'l> { /// Return the number of columns. #[inline] - pub fn count(&self) -> usize { + pub fn column_count(&self) -> usize { unsafe { ffi::sqlite3_column_count(self.raw.0) as usize } } @@ -59,7 +59,7 @@ impl<'l> Statement<'l> { /// /// The type becomes available after taking a step. pub fn kind(&self, i: usize) -> Type { - debug_assert!(i < self.count(), "the index is out of range"); + debug_assert!(i < self.column_count(), "the index is out of range"); match unsafe { ffi::sqlite3_column_type(self.raw.0, i as c_int) } { ffi::SQLITE_BLOB => Type::Binary, ffi::SQLITE_FLOAT => Type::Float, @@ -73,7 +73,7 @@ impl<'l> Statement<'l> { /// Return the name of a column. #[inline] pub fn name(&self, i: usize) -> &str { - debug_assert!(i < self.count(), "the index is out of range"); + debug_assert!(i < self.column_count(), "the index is out of range"); unsafe { let pointer = ffi::sqlite3_column_name(self.raw.0, i as c_int); debug_assert!(!pointer.is_null()); @@ -84,7 +84,7 @@ impl<'l> Statement<'l> { /// Return column names. #[inline] pub fn names(&self) -> Vec<&str> { - (0..self.count()).map(|i| self.name(i)).collect() + (0..self.column_count()).map(|i| self.name(i)).collect() } /// Advance to the next state. @@ -104,7 +104,7 @@ impl<'l> Statement<'l> { /// The leftmost column has the index 0. #[inline] pub fn read(&self, i: usize) -> Result { - debug_assert!(i < self.count(), "the index is out of range"); + debug_assert!(i < self.column_count(), "the index is out of range"); Readable::read(self, i) } diff --git a/tests/lib.rs b/tests/lib.rs index 8e45139..902a288 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -233,14 +233,14 @@ fn statement_bind_with_optional() { } #[test] -fn statement_count() { +fn statement_column_count() { let connection = setup_users(":memory:"); let statement = "SELECT * FROM users"; let mut statement = ok!(connection.prepare(statement)); assert_eq!(ok!(statement.next()), State::Row); - assert_eq!(statement.count(), 5); + assert_eq!(statement.column_count(), 5); } #[test]