Rename count to column_count

This commit is contained in:
Ivan Ukhov 2020-06-13 08:51:55 +02:00
parent f2cf430385
commit e6da9fd6f7
3 changed files with 10 additions and 10 deletions

View File

@ -22,8 +22,8 @@ impl<'l> Cursor<'l> {
/// Return the number of columns. /// Return the number of columns.
#[inline] #[inline]
pub fn count(&self) -> usize { pub fn column_count(&self) -> usize {
self.statement.count() self.statement.column_count()
} }
/// Advance to the next row and read all columns. /// Advance to the next row and read all columns.
@ -44,7 +44,7 @@ impl<'l> Cursor<'l> {
Some(values) Some(values)
} }
_ => { _ => {
let count = self.statement.count(); let count = self.statement.column_count();
let mut values = Vec::with_capacity(count); let mut values = Vec::with_capacity(count);
for i in 0..count { for i in 0..count {
values.push(self.statement.read(i)?); values.push(self.statement.read(i)?);

View File

@ -51,7 +51,7 @@ impl<'l> Statement<'l> {
/// Return the number of columns. /// Return the number of columns.
#[inline] #[inline]
pub fn count(&self) -> usize { pub fn column_count(&self) -> usize {
unsafe { ffi::sqlite3_column_count(self.raw.0) as 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. /// The type becomes available after taking a step.
pub fn kind(&self, i: usize) -> Type { 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) } { match unsafe { ffi::sqlite3_column_type(self.raw.0, i as c_int) } {
ffi::SQLITE_BLOB => Type::Binary, ffi::SQLITE_BLOB => Type::Binary,
ffi::SQLITE_FLOAT => Type::Float, ffi::SQLITE_FLOAT => Type::Float,
@ -73,7 +73,7 @@ impl<'l> Statement<'l> {
/// Return the name of a column. /// Return the name of a column.
#[inline] #[inline]
pub fn name(&self, i: usize) -> &str { 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 { unsafe {
let pointer = ffi::sqlite3_column_name(self.raw.0, i as c_int); let pointer = ffi::sqlite3_column_name(self.raw.0, i as c_int);
debug_assert!(!pointer.is_null()); debug_assert!(!pointer.is_null());
@ -84,7 +84,7 @@ impl<'l> Statement<'l> {
/// Return column names. /// Return column names.
#[inline] #[inline]
pub fn names(&self) -> Vec<&str> { 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. /// Advance to the next state.
@ -104,7 +104,7 @@ impl<'l> Statement<'l> {
/// The leftmost column has the index 0. /// The leftmost column has the index 0.
#[inline] #[inline]
pub fn read<T: Readable>(&self, i: usize) -> Result<T> { pub fn read<T: Readable>(&self, i: usize) -> Result<T> {
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) Readable::read(self, i)
} }

View File

@ -233,14 +233,14 @@ fn statement_bind_with_optional() {
} }
#[test] #[test]
fn statement_count() { fn statement_column_count() {
let connection = setup_users(":memory:"); let connection = setup_users(":memory:");
let statement = "SELECT * FROM users"; let statement = "SELECT * FROM users";
let mut statement = ok!(connection.prepare(statement)); let mut statement = ok!(connection.prepare(statement));
assert_eq!(ok!(statement.next()), State::Row); assert_eq!(ok!(statement.next()), State::Row);
assert_eq!(statement.count(), 5); assert_eq!(statement.column_count(), 5);
} }
#[test] #[test]