pub struct OwnedQuery { /* private fields */ }Expand description
Helper for query string parsing.
You may also need Query if you just want a borrowed version.
This is an auto-generated wrapper over Arc<HashMap<Arc<str>, Arc<str>, foldhash::fast::RandomState>>
Implementations§
Source§impl OwnedQuery
impl OwnedQuery
Sourcepub const fn new(inner: Arc<HashMap<Arc<str>, Arc<str>, RandomState>>) -> Self
pub const fn new(inner: Arc<HashMap<Arc<str>, Arc<str>, RandomState>>) -> Self
Creates a new instance of OwnedQuery
Source§impl OwnedQuery
impl OwnedQuery
Sourcepub fn get<Q>(&self, k: &Q) -> Option<&str>
pub fn get<Q>(&self, k: &Q) -> Option<&str>
Since OwnedQuery is a wrapper of Arc<HashMap<Arc<str>, Arc<str>>> and implements Deref, without this you can still call
HashMap::get (though auto deref), however you will get an
Option<&Arc<str>>, and &Arc<str> is probably not what you want.
Here’s an example:
let data: OwnedQuery = ...;
let example = data.get("example").unwrap(); // &Arc<str>
assert!(example, "example");assert!(example, "example") will not compile at all, you must change
it to assert!(&**example, "example"):
& * *example
││└ &Arc<str> deref to Arc<str>
│└ Arc<str> deref to str
└ &strThis is really not convenient and graceful, so we provide this method as
an replacement of HashMap::get.
See The Rustonomicon - The Dot Operator for the reason why we can do so.
Trait Implementations§
Source§impl Clone for OwnedQuery
impl Clone for OwnedQuery
Source§fn clone(&self) -> OwnedQuery
fn clone(&self) -> OwnedQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more