|
6 | 6 | // option. This file may not be copied, modified, or distributed
|
7 | 7 | // except according to those terms.
|
8 | 8 |
|
9 |
| -#![crate_name = "url_"] |
10 |
| -#![crate_type = "dylib"] |
11 |
| -#![crate_type = "rlib"] |
| 9 | +#![crate_name = "url"] |
12 | 10 |
|
13 | 11 | //! <a href="https://github.com/servo/rust-url"><img style="position: absolute; top: 0; left: 0; border: 0;" src="../github.png" alt="Fork me on GitHub"></a>
|
14 | 12 | //! <style>.sidebar { display: none }</style>
|
|
29 | 27 | //!
|
30 | 28 | //! rust-url is a replacement of the [`url` crate](http://doc.rust-lang.org/url/index.html)
|
31 | 29 | //! currently distributed with Rust.
|
32 |
| -//! rust-url’s crate is currently named `url_` with an underscore to avoid a naming conflict, |
33 |
| -//! but the intent is to rename it to just `url` when the old crate eventually |
34 |
| -//! [goes away](https://github.com/rust-lang/rust/issues/15874). |
35 |
| -//! Therefore, it is recommended that you use this crate as follows: |
| 30 | +//! rust-url’s crate is also named `url`. |
| 31 | +//! Cargo will automatically resolve the name conflict, |
| 32 | +//! but that means that you can not also use the old `url` in the same crate. |
36 | 33 | //!
|
37 |
| -//! ```ignore |
38 |
| -//! extern crate url = "url_"; |
39 |
| -//! |
40 |
| -//! use url::{Url, ...}; |
41 |
| -//! ``` |
42 |
| -//! |
43 |
| -//! That way, when the renaming is done, you will only need to change the `extern crate` line. |
| 34 | +//! If you’re not using Cargo, you’ll need to pass `--extern url=/path/to/liburl.rlib` |
| 35 | +//! explicitly to rustc. |
44 | 36 | //!
|
45 | 37 | //!
|
46 | 38 | //! # URL parsing and data structures
|
47 | 39 | //!
|
48 | 40 | //! First, URL parsing may fail for various reasons and therefore returns a `Result`.
|
49 | 41 | //!
|
50 | 42 | //! ```
|
51 |
| -//! # use url_::Url; |
| 43 | +//! use url::Url; |
| 44 | +//! |
52 | 45 | //! assert!(Url::parse("http://[:::1]") == Err("Invalid IPv6 address"))
|
53 | 46 | //! ```
|
54 | 47 | //!
|
55 | 48 | //! Let’s parse a valid URL and look at its components.
|
56 | 49 | //!
|
57 | 50 | //! ```
|
58 |
| -//! # use url_::{Url, RelativeSchemeData, NonRelativeSchemeData}; |
| 51 | +//! use url::{Url, RelativeSchemeData, NonRelativeSchemeData}; |
| 52 | +//! |
59 | 53 | //! let issue_list_url = Url::parse(
|
60 | 54 | //! "https://github.com/rust-lang/rust/issues?labels=E-easy&state=open"
|
61 | 55 | //! ).unwrap();
|
|
81 | 75 | //! “in a relative scheme”. `https` is a relative scheme, but `data` is not:
|
82 | 76 | //!
|
83 | 77 | //! ```
|
84 |
| -//! # use url_::{Url, NonRelativeSchemeData}; |
| 78 | +//! use url::{Url, NonRelativeSchemeData}; |
| 79 | +//! |
85 | 80 | //! let data_url = Url::parse("data:text/plain,Hello#").unwrap();
|
86 | 81 | //!
|
87 | 82 | //! assert!(data_url.scheme == "data".to_string());
|
|
103 | 98 | //! Since parsed URL are absolute, giving a base is required:
|
104 | 99 | //!
|
105 | 100 | //! ```
|
106 |
| -//! # use url_::Url; |
| 101 | +//! use url::Url; |
| 102 | +//! |
107 | 103 | //! assert!(Url::parse("../main.css") == Err("Relative URL without a base"))
|
108 | 104 | //! ```
|
109 | 105 | //!
|
110 | 106 | //! `UrlParser` is a method-chaining API to provide various optional parameters
|
111 | 107 | //! to URL parsing, including a base URL.
|
112 | 108 | //!
|
113 | 109 | //! ```
|
114 |
| -//! # use url_::{Url, UrlParser}; |
| 110 | +//! use url::{Url, UrlParser}; |
| 111 | +//! |
115 | 112 | //! let this_document = Url::parse("http://servo.github.io/rust-url/url/index.html").unwrap();
|
116 | 113 | //! let css_url = UrlParser::new().base_url(&this_document).parse("../main.css").unwrap();
|
117 | 114 | //! assert!(css_url.serialize() == "http://servo.github.io/rust-url/main.css".to_string());
|
|
0 commit comments