@@ -22,21 +22,35 @@ use std::uint;
22
22
/// A Uniform Resource Locator (URL). A URL is a form of URI (Uniform Resource
23
23
/// Identifier) that includes network location information, such as hostname or
24
24
/// port number.
25
+ ///
26
+ /// # Example
27
+ ///
28
+ /// ```rust
29
+ /// let url = Url { scheme: ~"https",
30
+ /// user: Some(UserInfo { user: ~"username", pass: None }),
31
+ /// host: ~"example.com",
32
+ /// port: Some(~"8080"),
33
+ /// path: ~"/foo/bar",
34
+ /// query: ~[(~"baz", ~"qux")],
35
+ /// fragment: Some(~"quz") };
36
+ /// // https://[email protected] :8080/foo/bar?baz=qux#quz
37
+ /// ```
25
38
#[ deriving( Clone , Eq ) ]
26
39
pub struct Url {
27
- /// The scheme part of a URL, such as `http`, `ftp` or `mailto` .
40
+ /// The scheme part of a URL, such as `https` in the above example .
28
41
scheme : ~str ,
29
- /// A URL subcomponent for user authentication.
42
+ /// A URL subcomponent for user authentication. `username` in the above example.
30
43
user : Option < UserInfo > ,
31
- /// A domain name or IP address. For example, `www. example.com`.
44
+ /// A domain name or IP address. For example, `example.com`.
32
45
host : ~str ,
33
46
/// A TCP port number, for example `8080`.
34
47
port : Option < ~str > ,
35
- /// The path component of a URL, for example `/users/jsmith `.
48
+ /// The path component of a URL, for example `/foo/bar `.
36
49
path : ~str ,
37
- /// The query component of a URL.
50
+ /// The query component of a URL. `~[(~"baz", ~"qux")]` represents the
51
+ /// fragment `baz=qux` in the above example.
38
52
query : Query ,
39
- /// The fragment component. Does not include the leading hash or pound sign .
53
+ /// The fragment component, such as `quz`. Doesn't include the leading `#` character .
40
54
fragment : Option < ~str >
41
55
}
42
56
0 commit comments