mirror of
https://github.com/openharmony/third_party_rust_http.git
synced 2026-07-19 14:43:33 -04:00
add Uri::into_parts inherent method (#214)
This commit is contained in:
@@ -288,6 +288,31 @@ impl Uri {
|
||||
parse_full(s)
|
||||
}
|
||||
|
||||
/// Convert a `Uri` into `Parts`.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This is just an inherent method providing the same functionality as
|
||||
/// `let parts: Parts = uri.into()`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use http::uri::*;
|
||||
/// let uri: Uri = "/foo".parse().unwrap();
|
||||
///
|
||||
/// let parts = uri.into_parts();
|
||||
///
|
||||
/// assert_eq!(parts.path_and_query.unwrap(), "/foo");
|
||||
///
|
||||
/// assert!(parts.scheme.is_none());
|
||||
/// assert!(parts.authority.is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn into_parts(self) -> Parts {
|
||||
self.into()
|
||||
}
|
||||
|
||||
/// Returns the path & query components of the Uri
|
||||
#[inline]
|
||||
pub fn path_and_query(&self) -> Option<&PathAndQuery> {
|
||||
|
||||
Reference in New Issue
Block a user