From a8d34da2d58574c2e499a43914649ea4c5415cc1 Mon Sep 17 00:00:00 2001 From: Pro Date: Thu, 22 Aug 2019 16:53:16 +0200 Subject: [PATCH] Use the correct (larger) lifetime of the returned column-related references in Row, Rows and Column --- src/column.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/column.rs b/src/column.rs index 8036f26..ae5c907 100644 --- a/src/column.rs +++ b/src/column.rs @@ -9,14 +9,14 @@ pub struct Column<'stmt> { decl_type: Option<&'stmt str>, } -impl Column<'_> { +impl<'stmt> Column<'stmt> { /// Returns the name of the column. - pub fn name(&self) -> &str { + pub fn name(&self) -> &'stmt str { self.name } /// Returns the type of the column (`None` for expression). - pub fn decl_type(&self) -> Option<&str> { + pub fn decl_type(&self) -> Option<&'stmt str> { self.decl_type } } @@ -68,7 +68,7 @@ impl Statement<'_> { } /// Returns a slice describing the columns of the result of the query. - pub fn columns<'stmt>(&'stmt self) -> Vec> { + pub fn columns(&self) -> Vec { let n = self.column_count(); let mut cols = Vec::with_capacity(n as usize); for i in 0..n { @@ -83,7 +83,7 @@ impl Statement<'_> { impl<'stmt> Rows<'stmt> { /// Get all the column names. - pub fn column_names(&self) -> Option> { + pub fn column_names(&self) -> Option> { self.stmt.map(Statement::column_names) } @@ -93,7 +93,7 @@ impl<'stmt> Rows<'stmt> { } /// Return the name of the column. - pub fn column_name(&self, col: usize) -> Option<&str> { + pub fn column_name(&self, col: usize) -> Option<&'stmt str> { self.stmt.and_then(|x| x.column_name(col)) } @@ -110,7 +110,7 @@ impl<'stmt> Rows<'stmt> { impl<'stmt> Row<'stmt> { /// Get all the column names of the Row. - pub fn column_names(&self) -> Vec<&str> { + pub fn column_names(&self) -> Vec<&'stmt str> { self.stmt.column_names() } @@ -120,7 +120,7 @@ impl<'stmt> Row<'stmt> { } /// Return the name of the column. - pub fn column_name(&self, col: usize) -> Option<&str> { + pub fn column_name(&self, col: usize) -> Option<&'stmt str> { self.stmt.column_name(col) }