Fail if PoolKey::new() cant find port
This commit is contained in:
13
src/pool.rs
13
src/pool.rs
@@ -52,9 +52,20 @@ struct PoolKey {
|
|||||||
|
|
||||||
impl PoolKey {
|
impl PoolKey {
|
||||||
fn new(url: &Url) -> Self {
|
fn new(url: &Url) -> Self {
|
||||||
|
let port = if cfg!(test) {
|
||||||
|
if let Some(p) = url.port_or_known_default() {
|
||||||
|
Some(p)
|
||||||
|
} else if url.scheme() == "test" {
|
||||||
|
Some(42)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
url.port_or_known_default()
|
||||||
|
};
|
||||||
PoolKey {
|
PoolKey {
|
||||||
hostname: url.host_str().unwrap_or(DEFAULT_HOST).into(),
|
hostname: url.host_str().unwrap_or(DEFAULT_HOST).into(),
|
||||||
port: url.port_or_known_default().unwrap_or(0),
|
port: port.expect("Failed to get port for pool key"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user