Skip to content

Commit 9358b80

Browse files
committed
refactor: change the position of unsafe wrapper
1 parent d29c48c commit 9358b80

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,25 @@ impl Url {
144144
/// assert_eq!(out.protocol(), "https:");
145145
/// ```
146146
pub fn parse(input: &str, base: Option<&str>) -> Result<Url, Error> {
147-
unsafe {
148-
let url_aggregator = match base {
149-
Some(base) => ada_parse_with_base(
147+
let url_aggregator = match base {
148+
Some(base) => unsafe {
149+
ada_parse_with_base(
150150
input.as_ptr().cast(),
151151
input.len(),
152152
base.as_ptr().cast(),
153153
base.len(),
154-
),
155-
None => ada_parse(input.as_ptr().cast(), input.len()),
156-
};
157-
158-
if ffi::ada_is_valid(url_aggregator) {
159-
Ok(Url {
160-
origin: None,
161-
url: url_aggregator,
162-
})
163-
} else {
164-
Err(Error::ParseUrl(input.to_owned()))
165-
}
154+
)
155+
},
156+
None => unsafe { ada_parse(input.as_ptr().cast(), input.len()) },
157+
};
158+
159+
if unsafe { ffi::ada_is_valid(url_aggregator) } {
160+
Ok(Url {
161+
origin: None,
162+
url: url_aggregator,
163+
})
164+
} else {
165+
Err(Error::ParseUrl(input.to_owned()))
166166
}
167167
}
168168

0 commit comments

Comments
 (0)