Abolish Host::into_string_and_port
When I was trying to add HS support to these layers, I found I could add a new variant to the `Host` enum but everything would still compile even though I hadn't written the necessary implementation! This method is a liability: when using it, one inevitably writes such latent bugs.
This commit is contained in:
parent
5df19bc888
commit
257b761042
|
@ -176,16 +176,6 @@ impl TorAddr {
|
|||
matches!(&self.host, Host::Ip(_))
|
||||
}
|
||||
|
||||
/// Extract a `String`-based hostname and a `u16` port from this
|
||||
/// address.
|
||||
//
|
||||
// TODO Remove this function - it is dangerously vague in semantics.
|
||||
pub(crate) fn into_string_and_port(self) -> (String, u16) {
|
||||
let host = self.host.to_string();
|
||||
let port = self.port;
|
||||
(host, port)
|
||||
}
|
||||
|
||||
/// Get instructions for how to make a stream to this address
|
||||
pub(crate) fn into_stream_instructions(self) -> StreamInstructions {
|
||||
// TODO enforcement of the config should go here, not separately
|
||||
|
@ -534,19 +524,6 @@ mod test {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn string_and_port() {
|
||||
fn sap(s: &str) -> (String, u16) {
|
||||
TorAddr::from(s).unwrap().into_string_and_port()
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
sap("[2001:db8::42]:9001"),
|
||||
("2001:db8::42".to_owned(), 9001)
|
||||
);
|
||||
assert_eq!(sap("example.com:80"), ("example.com".to_owned(), 80));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolve_instructions() {
|
||||
use ResolveInstructions as RI;
|
||||
|
|
Loading…
Reference in New Issue