Skip to content

Commit 43c569f

Browse files
committed
doc: add documentatin for parse and can_parse
1 parent 6de4b4b commit 43c569f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ impl Drop for Url {
136136
}
137137

138138
impl Url {
139+
/// Parses the input with an optional base
140+
///
141+
/// ```
142+
/// use ada_url::Url;
143+
/// let out = Url::parse("https://ada-url.github.io/ada", None)
144+
/// .expect("This is a valid URL. Should have parsed it.");
145+
/// assert_eq!(out.protocol(), "https:");
146+
/// ```
139147
pub fn parse(input: &str, base: Option<&str>) -> Result<Url, Error> {
140148
unsafe {
141149
let url_aggregator = match base {
@@ -159,6 +167,13 @@ impl Url {
159167
}
160168
}
161169

170+
/// Returns whether or not the URL can be parsed or not.
171+
///
172+
/// ```
173+
/// use ada_url::Url;
174+
/// assert!(Url::can_parse("https://ada-url.github.io/ada", None));
175+
/// assert!(Url::can_parse("/pathname", Some("https://ada-url.github.io/ada")));
176+
/// ```
162177
pub fn can_parse(input: &str, base: Option<&str>) -> bool {
163178
unsafe {
164179
if let Some(base) = base {

0 commit comments

Comments
 (0)