Skip to content

Commit 606407d

Browse files
alexpovelanonrig
authored andcommitted
fix: SetterError is no_std friendly
Now passes `just all`
1 parent c1817af commit 606407d

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

examples/simple.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
use ada_url::Url;
22

33
fn main() -> Result<(), Box<dyn std::error::Error>> {
4-
let mut u = Url::parse("http://www.google:8080/love#drug", None).expect("bad url");
5-
println!("port: {:?}", u.port());
6-
println!("hash: {:?}", u.hash());
7-
println!("pathname: {:?}", u.pathname());
8-
println!("href: {:?}", u.href());
9-
u.set_port(Some("9999"))?;
10-
println!("href: {:?}", u.href());
4+
let url = Url::parse("http://www.google:8080/love#drug", None).expect("bad url");
5+
6+
println!("port: {:?}", url.port());
7+
println!("hash: {:?}", url.hash());
8+
println!("pathname: {:?}", url.pathname());
9+
println!("href: {:?}", url.href());
10+
11+
let mut url = url;
12+
13+
#[cfg(feature = "std")]
14+
url.set_port(Some("9999"))?;
15+
16+
#[cfg(not(feature = "std"))]
17+
url.set_port(Some("9999")).unwrap();
18+
19+
println!("href: {:?}", url.href());
1120

1221
Ok(())
1322
}

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,9 @@ impl From<*mut ffi::ada_url> for Url {
180180
}
181181

182182
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Display)]
183+
#[cfg_attr(feature = "std", derive(derive_more::Error))] // error still requires std: https://github.com/rust-lang/rust/issues/103765
183184
pub struct SetterError;
184185

185-
impl std::error::Error for SetterError {}
186-
187186
type SetterResult = Result<(), SetterError>;
188187

189188
#[inline]

0 commit comments

Comments
 (0)