pub fn from_static(src: &'static str) -> Self {
        let s = src.as_bytes();
        let b = Bytes::from_static(s);
        let authority_end =
            Authority::parse_non_empty(&b[..]).expect("static str is not valid authority");

        if authority_end != b.len() {
            panic!("static str is not valid authority");
        }

        Authority {
            data: unsafe { ByteStr::from_utf8_unchecked(b) },
        }
    }
/// Attempt to convert an `Authority` from a static string.
///
/// This function will not perform any copying, and the string will be
/// checked if it is empty or contains an invalid character.
///
/// # Panics
///
/// This function panics if the argument contains invalid characters or
/// is empty.
///
/// # Examples
///
/// ```
/// # use http::uri::Authority;
/// let authority = Authority::from_static("example.com");
/// assert_eq!(authority.host(), "example.com");
/// ```
Attempt to convert an `Authority` from a static string.
This function will not perform any copying, and the string will be
checked if it is empty or contains an invalid character.
Attempt to convert an ` Authority ` from a static string . This function will not perform any copying and the string will be checked if it is empty or contains an invalid character .
pub fn from_static(src: &'static str) -> Self {
        let s = src.as_bytes();
        let b = Bytes::from_static(s);
        let authority_end =
            Authority::parse_non_empty(&b[..]).expect("static str is not valid authority");
        if authority_end != b.len() {
            panic!("static str is not valid authority");
        }
        Authority {
            data: unsafe { ByteStr::from_utf8_unchecked(b) },
        }
    }
pub fn from_static ( src : & ' static str ) -> Self { let s = src . as_bytes ( ) ; let b = Bytes :: from_static ( s ) ; let authority_end = Authority :: parse_non_empty ( & b [ .. ] ) . expect ( " " ) ; if authority_end != b . len ( ) { panic ! ( " " ) ; } Authority { data : unsafe { ByteStr :: from_utf8_unchecked ( b ) } , } }
Attempt to convert an `Authority` from a static string.
Attempt to convert an ` Authority ` from a static string .
src
&'static str
src
&'static str
panics
This function panics if the argument contains invalid characters or
is empty.
This function panics if the argument contains invalid characters or is empty .
examples
None
use http::uri::authority;
let authority = Authority::from_static("example.com");
assert_eq!(authority.host(), "example.com");
```
let authority = Authority :: from_static ( " example . com " ) ; assert_eq! ( authority . host () " example . com " ) ; ` ` `