Skip to content

Commit

Permalink
result: fix wrong implied lifetime in col_specs()
Browse files Browse the repository at this point in the history
As `ColumnSpec` is now parametrised by a lifetime, methods that return
it implicitly bound its lifetime with lifetime of `&self`. This bug
would lead to inefficiencies.
As a fix, an explicit lifetime is added in every method returning
`ColumnSpec`.
  • Loading branch information
wprzytula committed Oct 28, 2024
1 parent 07553fe commit 8120d2f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scylla-cql/src/frame/response/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ impl<'a> ResultMetadata<'a> {
}

#[inline]
pub fn col_specs(&self) -> &[ColumnSpec] {
pub fn col_specs(&self) -> &[ColumnSpec<'a>] {
&self.col_specs
}
}
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/transport/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl RowIterator {
}

/// Returns specification of row columns
pub fn get_column_specs(&self) -> &[ColumnSpec] {
pub fn get_column_specs(&self) -> &[ColumnSpec<'static>] {
self.current_page.metadata.col_specs()
}

Expand Down
4 changes: 2 additions & 2 deletions scylla/src/transport/query_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl QueryResult {

/// Returns column specifications.
#[inline]
pub fn col_specs(&self) -> &[ColumnSpec] {
pub fn col_specs(&self) -> &[ColumnSpec<'static>] {
self.metadata
.as_ref()
.map(|metadata| metadata.col_specs())
Expand All @@ -147,7 +147,7 @@ impl QueryResult {

/// Returns a column specification for a column with given name, or None if not found
#[inline]
pub fn get_column_spec<'a>(&'a self, name: &str) -> Option<(usize, &'a ColumnSpec)> {
pub fn get_column_spec<'a>(&'a self, name: &str) -> Option<(usize, &'a ColumnSpec<'static>)> {
self.col_specs()
.iter()
.enumerate()
Expand Down

0 comments on commit 8120d2f

Please sign in to comment.