diff --git a/tonic/src/transport/channel/endpoint.rs b/tonic/src/transport/channel/endpoint.rs index da0d2c291..5889f64c5 100644 --- a/tonic/src/transport/channel/endpoint.rs +++ b/tonic/src/transport/channel/endpoint.rs @@ -50,6 +50,10 @@ impl Endpoint { /// Convert an `Endpoint` from a static string. /// + /// # Panics + /// + /// This function panics if the argument is an invalid URI. + /// /// ``` /// # use tonic::transport::Endpoint; /// Endpoint::from_static("https://example.com"); @@ -306,24 +310,13 @@ impl TryFrom for Endpoint { } impl TryFrom<&'static str> for Endpoint { - type Error = Never; + type Error = InvalidUri; fn try_from(t: &'static str) -> Result { - Ok(Self::from_static(t)) - } -} - -#[derive(Debug)] -pub enum Never {} - -impl std::fmt::Display for Never { - fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match *self {} + Self::from_shared(t.as_bytes()) } } -impl std::error::Error for Never {} - impl fmt::Debug for Endpoint { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Endpoint").finish()