Skip to content

Commit

Permalink
poem-openapi: fix lifetime of UrlQuery::get_all
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Aug 30, 2023
1 parent 87a443a commit a2a03c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"poem-derive",
"poem",
Expand Down
4 changes: 2 additions & 2 deletions poem-openapi/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ impl Deref for UrlQuery {

impl UrlQuery {
/// Returns all values with the specified name.
pub fn get_all<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a String> + 'a {
pub fn get_all<'a, 'b: 'a>(&'b self, name: &'a str) -> impl Iterator<Item = &'b String> + 'a {
self.0
.iter()
.filter(move |(n, _)| n == name)
.map(|(_, value)| value)
}

/// Returns the first value with the specified name.
pub fn get(&self, name: &str) -> Option<&String> {
pub fn get(&self, name: &str) -> Option<&str> {
self.get_all(name).next()
}
}
Expand Down

0 comments on commit a2a03c0

Please sign in to comment.