Remove find_col_named

It's a very simple utility function that won't be used enough to keep it
on a trait like PostgresStatement.
This commit is contained in:
Steven Fackler
2013-11-08 22:15:35 -08:00
parent d9a8e261f7
commit 2c4d4e97ea
2 changed files with 5 additions and 20 deletions

16
lib.rs
View File

@@ -926,14 +926,6 @@ pub trait PostgresStatement {
Err(err) => fail!("Error executing query:\n{}", err.to_str())
}
}
/// Returns the index of the first result column with the specified name,
/// or `None` if not found.
fn find_col_named(&self, col: &str) -> Option<uint> {
do self.result_descriptions().iter().position |desc| {
desc.name.as_slice() == col
}
}
}
/// A statement prepared outside of a transaction.
@@ -1296,9 +1288,11 @@ impl RowIndex for int {
impl<'self> RowIndex for &'self str {
#[inline]
fn idx(&self, stmt: &NormalPostgresStatement) -> uint {
match stmt.find_col_named(*self) {
Some(idx) => idx,
None => fail!("No column with name {}", *self)
for (i, desc) in stmt.result_descriptions().iter().enumerate() {
if desc.name.as_slice() == *self {
return i;
}
}
fail!("There is no colnum with name {}", *self);
}
}