Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From impls of PathAndQuery and Authority for Uri #538

Merged
merged 2 commits into from
Apr 28, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
From impls of PathAndQuery and Authority for Uri
A Uri may logically hold only an Authority or only a PathAndQuery.
Should an application want to make such Uris, it would be easier to
safely create them by first making just an Authority or just a
PathAndQuery, then cheaply convert them directly into a Uri.
  • Loading branch information
jeddenlea committed Apr 28, 2022
commit bd44ab804fc135f0d84c570a19cbe3391d291050
22 changes: 22 additions & 0 deletions src/uri/mod.rs
Original file line number Diff line number Diff line change
@@ -736,6 +736,28 @@ impl<'a> TryFrom<&'a Uri> for Uri {
}
}

/// Convert an `Authority` into a `Uri`.
impl From<Authority> for Uri {
fn from(authority: Authority) -> Self {
Self {
scheme: Scheme::empty(),
authority,
path_and_query: PathAndQuery::empty(),
}
}
}

/// Convert a `PathAndQuery` into a `Uri`.
impl From<PathAndQuery> for Uri {
fn from(path_and_query: PathAndQuery) -> Self {
Self {
scheme: Scheme::empty(),
authority: Authority::empty(),
path_and_query,
}
}
}

/// Convert a `Uri` from parts
///
/// # Examples