Skip to content

Commit

Permalink
feat: implement from uri for builder
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored and seanmonstar committed Jan 31, 2024
1 parent 9098a29 commit f446500
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/uri/builder.rs
Expand Up @@ -152,6 +152,14 @@ impl Default for Builder {
}
}

impl From<Uri> for Builder {
fn from(uri: Uri) -> Self {
Self {
parts: Ok(uri.into_parts()),
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -193,4 +201,11 @@ mod tests {
assert_eq!(uri.query(), Some(expected_query.as_str()));
}
}

#[test]
fn build_from_uri() {
let original_uri = Uri::default();
let uri = Builder::from(original_uri.clone()).build().unwrap();
assert_eq!(original_uri, uri);
}
}

0 comments on commit f446500

Please sign in to comment.