File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,7 @@ impl Url {
223
223
}
224
224
225
225
/// Return the parsed version of the URL with all components.
226
+ ///
226
227
/// For more information, read [WHATWG URL spec](https://url.spec.whatwg.org/#dom-url-href)
227
228
pub fn href ( & self ) -> & str {
228
229
unsafe { ffi:: ada_get_href ( self . url ) } . as_str ( )
@@ -446,6 +447,30 @@ impl Url {
446
447
pub fn has_search ( & self ) -> bool {
447
448
unsafe { ffi:: ada_has_search ( self . url ) }
448
449
}
450
+ /// Returns the parsed version of the URL with all components.
451
+ ///
452
+ /// For more information, read [WHATWG URL spec](https://url.spec.whatwg.org/#dom-url-href)
453
+ pub fn as_str ( & self ) -> & str {
454
+ self . href ( )
455
+ }
456
+ }
457
+
458
+ impl std:: ops:: Deref for Url {
459
+ type Target = str ;
460
+ fn deref ( & self ) -> & Self :: Target {
461
+ self . href ( )
462
+ }
463
+ }
464
+ impl AsRef < str > for Url {
465
+ fn as_ref ( & self ) -> & str {
466
+ self . href ( )
467
+ }
468
+ }
469
+
470
+ impl std:: fmt:: Display for Url {
471
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
472
+ f. write_str ( self . href ( ) )
473
+ }
449
474
}
450
475
451
476
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments