method SocketAddr.parse
ip:port or [v6]:port with numeric addresses (SocketAddr.parse("127.0.0.1:8080")).
Example:
use std.net { SocketAddr }
fn main() io {
match SocketAddr.parse("localhost:80") {
SocketAddr a => print(a.toString())
ParseError e => print(e.msg)
}
}Вывод
invalid socket address `localhost:80`
pub(api) static fn parse(text: str) -> SocketAddr | ParseErrorСложность. O(n) in the length of the text.
С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
text | str |
Возвращает
Ошибки
ParseError@error- `ParseError` when the text is not `ip:port` / `[v6]:port` with a numeric address and a port in 0..65535.
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/net/net.oxl:294