Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Url::port_or_default()
1 parent 2d81b9f commit 7484db5Copy full SHA for 7484db5
1 file changed
git-url/src/lib.rs
@@ -92,6 +92,20 @@ impl Url {
92
pub fn path_is_root(&self) -> bool {
93
self.path == "/"
94
}
95
+ /// Returns the actual or default port for use according to the url scheme.
96
+ /// Note that there may be no default port either.
97
+ pub fn port_or_default(&self) -> Option<u16> {
98
+ self.port.or_else(|| {
99
+ use Scheme::*;
100
+ Some(match self.scheme {
101
+ Http => 80,
102
+ Https => 443,
103
+ Ssh => 21,
104
+ Git => 9418,
105
+ File | Ext(_) => return None,
106
+ })
107
108
+ }
109
110
111
/// Serialization
0 commit comments