@@ -179,14 +179,19 @@ impl From<*mut ffi::ada_url> for Url {
179
179
}
180
180
}
181
181
182
- type SetterResult = Result < ( ) , ( ) > ;
182
+ #[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Default , Display ) ]
183
+ pub struct SetterError ;
184
+
185
+ impl std:: error:: Error for SetterError { }
186
+
187
+ type SetterResult = Result < ( ) , SetterError > ;
183
188
184
189
#[ inline]
185
190
fn setter_result ( successful : bool ) -> SetterResult {
186
191
if successful {
187
192
Ok ( ( ) )
188
193
} else {
189
- Err ( ( ) )
194
+ Err ( SetterError )
190
195
}
191
196
}
192
197
@@ -290,7 +295,6 @@ impl Url {
290
295
/// url.set_href("https://lemire.me").unwrap();
291
296
/// assert_eq!(url.href(), "https://lemire.me/");
292
297
/// ```
293
- #[ allow( clippy:: result_unit_err) ]
294
298
pub fn set_href ( & mut self , input : & str ) -> SetterResult {
295
299
setter_result ( unsafe { ffi:: ada_set_href ( self . 0 , input. as_ptr ( ) . cast ( ) , input. len ( ) ) } )
296
300
}
@@ -318,7 +322,6 @@ impl Url {
318
322
/// url.set_username(Some("username")).unwrap();
319
323
/// assert_eq!(url.href(), "https://[email protected] /");
320
324
/// ```
321
- #[ allow( clippy:: result_unit_err) ]
322
325
pub fn set_username ( & mut self , input : Option < & str > ) -> SetterResult {
323
326
setter_result ( unsafe {
324
327
ffi:: ada_set_username (
@@ -352,7 +355,6 @@ impl Url {
352
355
/// url.set_password(Some("password")).unwrap();
353
356
/// assert_eq!(url.href(), "https://:[email protected] /");
354
357
/// ```
355
- #[ allow( clippy:: result_unit_err) ]
356
358
pub fn set_password ( & mut self , input : Option < & str > ) -> SetterResult {
357
359
setter_result ( unsafe {
358
360
ffi:: ada_set_password (
@@ -389,7 +391,6 @@ impl Url {
389
391
/// url.set_port(Some("8080")).unwrap();
390
392
/// assert_eq!(url.href(), "https://yagiz.co:8080/");
391
393
/// ```
392
- #[ allow( clippy:: result_unit_err) ]
393
394
pub fn set_port ( & mut self , input : Option < & str > ) -> SetterResult {
394
395
match input {
395
396
Some ( value) => setter_result ( unsafe {
@@ -462,7 +463,6 @@ impl Url {
462
463
/// url.set_host(Some("localhost:3000")).unwrap();
463
464
/// assert_eq!(url.href(), "https://localhost:3000/");
464
465
/// ```
465
- #[ allow( clippy:: result_unit_err) ]
466
466
pub fn set_host ( & mut self , input : Option < & str > ) -> SetterResult {
467
467
setter_result ( unsafe {
468
468
ffi:: ada_set_host (
@@ -500,7 +500,6 @@ impl Url {
500
500
/// url.set_hostname(Some("localhost")).unwrap();
501
501
/// assert_eq!(url.href(), "https://localhost/");
502
502
/// ```
503
- #[ allow( clippy:: result_unit_err) ]
504
503
pub fn set_hostname ( & mut self , input : Option < & str > ) -> SetterResult {
505
504
setter_result ( unsafe {
506
505
ffi:: ada_set_hostname (
@@ -534,7 +533,6 @@ impl Url {
534
533
/// url.set_pathname(Some("/contact")).unwrap();
535
534
/// assert_eq!(url.href(), "https://yagiz.co/contact");
536
535
/// ```
537
- #[ allow( clippy:: result_unit_err) ]
538
536
pub fn set_pathname ( & mut self , input : Option < & str > ) -> SetterResult {
539
537
setter_result ( unsafe {
540
538
ffi:: ada_set_pathname (
@@ -603,7 +601,6 @@ impl Url {
603
601
/// url.set_protocol("http").unwrap();
604
602
/// assert_eq!(url.href(), "http://yagiz.co/");
605
603
/// ```
606
- #[ allow( clippy:: result_unit_err) ]
607
604
pub fn set_protocol ( & mut self , input : & str ) -> SetterResult {
608
605
setter_result ( unsafe { ffi:: ada_set_protocol ( self . 0 , input. as_ptr ( ) . cast ( ) , input. len ( ) ) } )
609
606
}
0 commit comments