66// option. This file may not be copied, modified, or distributed
77// except according to those terms.
88
9- //! Getters and setters for URL components implemented per https://url.spec.whatwg.org/#api
9+ //! Getters and setters for URL components implemented per < https://url.spec.whatwg.org/#api>
1010//!
1111//! Unless you need to be interoperable with web browsers,
1212//! you probably want to use `Url` method instead.
@@ -57,15 +57,15 @@ pub fn internal_components(url: &Url) -> InternalComponents {
5757 }
5858}
5959
60- /// https://url.spec.whatwg.org/#dom-url-domaintoascii
60+ /// < https://url.spec.whatwg.org/#dom-url-domaintoascii>
6161pub fn domain_to_ascii ( domain : & str ) -> String {
6262 match Host :: parse ( domain) {
6363 Ok ( Host :: Domain ( domain) ) => domain,
6464 _ => String :: new ( ) ,
6565 }
6666}
6767
68- /// https://url.spec.whatwg.org/#dom-url-domaintounicode
68+ /// < https://url.spec.whatwg.org/#dom-url-domaintounicode>
6969pub fn domain_to_unicode ( domain : & str ) -> String {
7070 match Host :: parse ( domain) {
7171 Ok ( Host :: Domain ( ref domain) ) => {
@@ -76,29 +76,29 @@ pub fn domain_to_unicode(domain: &str) -> String {
7676 }
7777}
7878
79- /// Getter for https://url.spec.whatwg.org/#dom-url-href
79+ /// Getter for < https://url.spec.whatwg.org/#dom-url-href>
8080pub fn href ( url : & Url ) -> & str {
8181 url. as_str ( )
8282}
8383
84- /// Setter for https://url.spec.whatwg.org/#dom-url-href
84+ /// Setter for < https://url.spec.whatwg.org/#dom-url-href>
8585pub fn set_href ( url : & mut Url , value : & str ) -> Result < ( ) , ParseError > {
8686 * url = Url :: parse ( value) ?;
8787 Ok ( ( ) )
8888}
8989
90- /// Getter for https://url.spec.whatwg.org/#dom-url-origin
90+ /// Getter for < https://url.spec.whatwg.org/#dom-url-origin>
9191pub fn origin ( url : & Url ) -> String {
9292 url. origin ( ) . ascii_serialization ( )
9393}
9494
95- /// Getter for https://url.spec.whatwg.org/#dom-url-protocol
95+ /// Getter for < https://url.spec.whatwg.org/#dom-url-protocol>
9696#[ inline]
9797pub fn protocol ( url : & Url ) -> & str {
9898 & url. as_str ( ) [ ..url. scheme ( ) . len ( ) + ":" . len ( ) ]
9999}
100100
101- /// Setter for https://url.spec.whatwg.org/#dom-url-protocol
101+ /// Setter for < https://url.spec.whatwg.org/#dom-url-protocol>
102102#[ allow( clippy:: result_unit_err) ]
103103pub fn set_protocol ( url : & mut Url , mut new_protocol : & str ) -> Result < ( ) , ( ) > {
104104 // The scheme state in the spec ignores everything after the first `:`,
@@ -109,25 +109,25 @@ pub fn set_protocol(url: &mut Url, mut new_protocol: &str) -> Result<(), ()> {
109109 url. set_scheme ( new_protocol)
110110}
111111
112- /// Getter for https://url.spec.whatwg.org/#dom-url-username
112+ /// Getter for < https://url.spec.whatwg.org/#dom-url-username>
113113#[ inline]
114114pub fn username ( url : & Url ) -> & str {
115115 url. username ( )
116116}
117117
118- /// Setter for https://url.spec.whatwg.org/#dom-url-username
118+ /// Setter for < https://url.spec.whatwg.org/#dom-url-username>
119119#[ allow( clippy:: result_unit_err) ]
120120pub fn set_username ( url : & mut Url , new_username : & str ) -> Result < ( ) , ( ) > {
121121 url. set_username ( new_username)
122122}
123123
124- /// Getter for https://url.spec.whatwg.org/#dom-url-password
124+ /// Getter for < https://url.spec.whatwg.org/#dom-url-password>
125125#[ inline]
126126pub fn password ( url : & Url ) -> & str {
127127 url. password ( ) . unwrap_or ( "" )
128128}
129129
130- /// Setter for https://url.spec.whatwg.org/#dom-url-password
130+ /// Setter for < https://url.spec.whatwg.org/#dom-url-password>
131131#[ allow( clippy:: result_unit_err) ]
132132pub fn set_password ( url : & mut Url , new_password : & str ) -> Result < ( ) , ( ) > {
133133 url. set_password ( if new_password. is_empty ( ) {
@@ -137,13 +137,13 @@ pub fn set_password(url: &mut Url, new_password: &str) -> Result<(), ()> {
137137 } )
138138}
139139
140- /// Getter for https://url.spec.whatwg.org/#dom-url-host
140+ /// Getter for < https://url.spec.whatwg.org/#dom-url-host>
141141#[ inline]
142142pub fn host ( url : & Url ) -> & str {
143143 & url[ Position :: BeforeHost ..Position :: AfterPort ]
144144}
145145
146- /// Setter for https://url.spec.whatwg.org/#dom-url-host
146+ /// Setter for < https://url.spec.whatwg.org/#dom-url-host>
147147#[ allow( clippy:: result_unit_err) ]
148148pub fn set_host ( url : & mut Url , new_host : & str ) -> Result < ( ) , ( ) > {
149149 // If context object’s url’s cannot-be-a-base-URL flag is set, then return.
@@ -190,13 +190,13 @@ pub fn set_host(url: &mut Url, new_host: &str) -> Result<(), ()> {
190190 Ok ( ( ) )
191191}
192192
193- /// Getter for https://url.spec.whatwg.org/#dom-url-hostname
193+ /// Getter for < https://url.spec.whatwg.org/#dom-url-hostname>
194194#[ inline]
195195pub fn hostname ( url : & Url ) -> & str {
196196 url. host_str ( ) . unwrap_or ( "" )
197197}
198198
199- /// Setter for https://url.spec.whatwg.org/#dom-url-hostname
199+ /// Setter for < https://url.spec.whatwg.org/#dom-url-hostname>
200200#[ allow( clippy:: result_unit_err) ]
201201pub fn set_hostname ( url : & mut Url , new_hostname : & str ) -> Result < ( ) , ( ) > {
202202 if url. cannot_be_a_base ( ) {
@@ -232,13 +232,13 @@ pub fn set_hostname(url: &mut Url, new_hostname: &str) -> Result<(), ()> {
232232 }
233233}
234234
235- /// Getter for https://url.spec.whatwg.org/#dom-url-port
235+ /// Getter for < https://url.spec.whatwg.org/#dom-url-port>
236236#[ inline]
237237pub fn port ( url : & Url ) -> & str {
238238 & url[ Position :: BeforePort ..Position :: AfterPort ]
239239}
240240
241- /// Setter for https://url.spec.whatwg.org/#dom-url-port
241+ /// Setter for < https://url.spec.whatwg.org/#dom-url-port>
242242#[ allow( clippy:: result_unit_err) ]
243243pub fn set_port ( url : & mut Url , new_port : & str ) -> Result < ( ) , ( ) > {
244244 let result;
@@ -262,13 +262,13 @@ pub fn set_port(url: &mut Url, new_port: &str) -> Result<(), ()> {
262262 }
263263}
264264
265- /// Getter for https://url.spec.whatwg.org/#dom-url-pathname
265+ /// Getter for < https://url.spec.whatwg.org/#dom-url-pathname>
266266#[ inline]
267267pub fn pathname ( url : & Url ) -> & str {
268268 url. path ( )
269269}
270270
271- /// Setter for https://url.spec.whatwg.org/#dom-url-pathname
271+ /// Setter for < https://url.spec.whatwg.org/#dom-url-pathname>
272272pub fn set_pathname ( url : & mut Url , new_pathname : & str ) {
273273 if url. cannot_be_a_base ( ) {
274274 return ;
@@ -291,12 +291,12 @@ pub fn set_pathname(url: &mut Url, new_pathname: &str) {
291291 }
292292}
293293
294- /// Getter for https://url.spec.whatwg.org/#dom-url-search
294+ /// Getter for < https://url.spec.whatwg.org/#dom-url-search>
295295pub fn search ( url : & Url ) -> & str {
296296 trim ( & url[ Position :: AfterPath ..Position :: AfterQuery ] )
297297}
298298
299- /// Setter for https://url.spec.whatwg.org/#dom-url-search
299+ /// Setter for < https://url.spec.whatwg.org/#dom-url-search>
300300pub fn set_search ( url : & mut Url , new_search : & str ) {
301301 url. set_query ( match new_search {
302302 "" => None ,
@@ -305,12 +305,12 @@ pub fn set_search(url: &mut Url, new_search: &str) {
305305 } )
306306}
307307
308- /// Getter for https://url.spec.whatwg.org/#dom-url-hash
308+ /// Getter for < https://url.spec.whatwg.org/#dom-url-hash>
309309pub fn hash ( url : & Url ) -> & str {
310310 trim ( & url[ Position :: AfterQuery ..] )
311311}
312312
313- /// Setter for https://url.spec.whatwg.org/#dom-url-hash
313+ /// Setter for < https://url.spec.whatwg.org/#dom-url-hash>
314314pub fn set_hash ( url : & mut Url , new_hash : & str ) {
315315 url. set_fragment ( match new_hash {
316316 // If the given value is the empty string,
0 commit comments