Skip to content

Commit 73d237b

Browse files
alexpovelanonrig
authored andcommitted
docs: Dedicated examples/
Files in `examples/` will be compiled by `cargo test`. Hence, uncompilable code will be caught from now on. One can `cargo run --example simple` to see the `println!` output. This allows users to get started hacking quickly.
1 parent 994a99c commit 73d237b

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

README.md

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,9 @@ It fully supports the relevant [Unicode Technical Standard](https://www.unicode.
88

99
### Usage
1010

11-
Here is an example illustrating a common usage:
12-
13-
```Rust
14-
use ada_url::Url;
15-
fn main() -> Result<(), Box<dyn std::error::Error>> {
16-
let mut u = Url::parse("http://www.google:8080/love#drug", None).expect("bad url");
17-
println!("port: {:?}", u.port());
18-
println!("hash: {:?}", u.hash());
19-
println!("pathname: {:?}", u.pathname());
20-
println!("href: {:?}", u.href());
21-
u.set_port(Some("9999"))?;
22-
println!("href: {:?}", u.href());
23-
24-
Ok(())
25-
}
26-
```
11+
See [here](examples/simple.rs) for a usage example.
12+
You can run it locally with `cargo run --example simple`.
13+
Feel free to adjust it for exploring this crate further.
2714

2815
#### Features
2916

examples/simple.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use ada_url::Url;
2+
3+
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());
11+
12+
Ok(())
13+
}

0 commit comments

Comments
 (0)