Skip to content

Commit 6b2ddd0

Browse files
chancedanonrig
authored andcommitted
updates ada_get_components return type
1 parent ef4a7d0 commit 6b2ddd0

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/lib.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub mod ffi {
9191
base: *const c_char,
9292
base_length: usize,
9393
) -> bool;
94-
pub fn ada_get_components(url: *mut ada_url) -> ada_url_components;
94+
pub fn ada_get_components(url: *mut ada_url) -> *mut ada_url_components;
9595

9696
// Getters
9797
pub fn ada_get_origin(url: *mut ada_url) -> ada_owned_string;
@@ -502,18 +502,20 @@ impl std::convert::AsRef<[u8]> for Url {
502502

503503
impl std::fmt::Debug for Url {
504504
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
505-
let components = unsafe { ffi::ada_get_components(self.url) };
506-
f.debug_struct("Url")
507-
.field("href", &self.href())
508-
.field("protocol_end", &components.protocol_end)
509-
.field("username_end", &components.username_end)
510-
.field("host_start", &components.host_start)
511-
.field("host_end", &components.host_end)
512-
.field("port", &components.port)
513-
.field("pathname_start", &components.pathname_start)
514-
.field("search_start", &components.search_start)
515-
.field("hash_start", &components.hash_start)
516-
.finish()
505+
unsafe {
506+
let components = ffi::ada_get_components(self.url).as_ref().unwrap();
507+
f.debug_struct("Url")
508+
.field("href", &self.href())
509+
.field("protocol_end", &components.protocol_end)
510+
.field("username_end", &components.username_end)
511+
.field("host_start", &components.host_start)
512+
.field("host_end", &components.host_end)
513+
.field("port", &components.port)
514+
.field("pathname_start", &components.pathname_start)
515+
.field("search_start", &components.search_start)
516+
.field("hash_start", &components.hash_start)
517+
.finish()
518+
}
517519
}
518520
}
519521

@@ -577,7 +579,7 @@ mod test {
577579
let tests = [("https://www.ada-url.com/playground")];
578580
for value in tests {
579581
let url = Url::parse(value, None).expect("Should have parsed url");
580-
println!("{:?}", url);
582+
println!("{:#?}", url);
581583
}
582584
}
583585

0 commit comments

Comments
 (0)